Universal Cup Judging System

Universal Cup

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100
Statistics

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.