QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 1024 MB Points totaux : 100

#15453. AMPPZ 评委会

Statistiques

AMPPZ 评委会由五人组成,他们负责创建一场有趣且平衡的比赛。今年,提交了 $n$ 个题目提案,必须从中选择 $k$ 个。每个评委独立地根据主观酷炫程度对题目进行排序,并为它们分配分数,这些分数构成 $1$ 到 $n$ 的一个排列*。然后,系统会自动选择平均分(算术平均值)最高的 $k$ 个题目。如果出现平局,则优先选择索引(编号)较小的题目。

四位评委已经对所有题目进行了评分。最后一位评委是 Jerzy,他暗地里喜欢计算几何,并希望 AMPPZ 的参赛者能尽可能多地体验到计算几何。对于每个题目,我们知道它是否是几何题($x_i \in \{0, 1\}$),并且我们知道其余评委给出的分数 $a_i, b_i, c_i, d_i$。如果 Jerzy 最优地分配他的分数(也是 $1$ 到 $n$ 的一个排列),那么被选中的几何题的最大可能数量是多少?

* 任意顺序、无重复的序列——例如 $(5, 4, 3, 2, 1)$ 或 $(2, 4, 1, 5, 3)$。

输入格式

第一行包含两个整数 $n$ 和 $k$($1 \le k \le n \le 200\,000$),分别表示提交的题目数量和比赛要选择的题目数量。

接下来的 $n$ 行描述提交的题目;其中第 $i$ 行包含五个整数 $x_i, a_i, b_i, c_i, d_i$($0 \le x_i \le 1$;$1 \le a_i, b_i, c_i, d_i \le n$),描述第 $i$ 个题目。如果该题目是几何主题,则 $x_i$ 的值为 $1$,否则为 $0$。接下来的四个数字是其余评委给出的分数。每个评委分配了 $n$ 个两两不同的分数,因此在输入中,除第一列外,每列都是 $1$ 到 $n$ 的一个排列。

输出格式

输出一个整数——被选中的几何题的最大可能数量。

样例

输入样例 1

5 3
1 3 5 5 2
0 5 2 4 5
1 2 3 3 4
1 1 1 1 1
0 4 4 2 3

输出样例 1

2

输入样例 2

4 3
1 1 4 1 2
1 2 3 2 1
0 3 2 3 3
0 4 1 4 4

输出样例 2

1

说明

在第一个样例中,评委会从五个提交的题目中选择三个。题目 1、3 和 4 是关于几何的。Jerzy 可以将分数 $(4, 5, 3, 1, 2)$ 分配给这五个题目:

  1. $x_1 = 1$;平均分为 $\frac{3+5+5+2+4}{5} = 3.8$
  2. $x_2 = 0$;平均分为 $\frac{5+2+4+5+5}{5} = 4.2$
  3. $x_3 = 1$;平均分为 $\frac{2+3+3+4+3}{5} = 3$
  4. $x_4 = 1$;平均分为 $\frac{1+1+1+1+1}{5} = 1$
  5. $x_5 = 0$;平均分为 $\frac{4+4+2+3+2}{5} = 3$

题目 1、2 和 3 将被选入比赛(题目 3 和 5 平均分相同,但题目 3 的索引较小)。选出的三个题目中有两个是几何题。Jerzy 无法让超过两个几何题被选中,因此答案为 2。

在第二个样例中,Jerzy 无法让两个几何题都被选中。它们都必须获得最高分 4,这是不可能的,因为 Jerzy 的分数必须两两不同。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.