Universal Cup Judging System

Universal Cup

시간 제한: 1.0 s 메모리 제한: 1024 MB 총점: 100
통계

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$ 個兩兩相異的分數,因此在輸入中,除第一行(column)外,每一行都是由 $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.