問題一覧 > 通常問題

No.433 I'd Be Happy If the ICPC Domestic Qualifier Selection Rules Were Like This

レベル : / AI推定難易度 : 1050 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 103
作問者 : mayoko_ / テスター : 🍡yurahuna
お気に入りにしたユーザー ProblemId : 684 / 自分の提出
問題文最終更新日: 2026-06-28 02:11:13
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 151 (順位表) の他の問題:

Problem Statement


A total of $N$ teams participated in the ICPC Domestic Qualifier. The $N$ teams are numbered $0, 1, ..., N-1$.

For each team, you are given the following information: the number of problems solved, the penalty, and which university the team belongs to. $K$ teams can advance past the Domestic Qualifier. These $K$ teams are determined one team at a time, based on the above information, using the following algorithm.

1. Among the teams not yet selected, select the team that solved the most problems.
2. If there are multiple teams not yet selected that solved the most problems, select the team with the smaller "number of teams from the same university selected so far".
3. If there are multiple teams not yet selected with the same number of problems solved and the same "number of teams from the same university selected so far", select the team with the smaller penalty.

Your task is to determine, from this information, which teams advanced past the Domestic Qualifier.

Input

$N$ $K$
$S_1$ $P_1$ $U_1$
$S_2$ $P_2$ $U_2$
...
$S_N$ $P_N$ $U_N$


The first line gives the number of participating teams $N$ and the number of teams to be selected $K$.
$1 \leq N \leq 10^5$, $1 \leq K \leq N$
The following $N$ lines give the information for each team. $S_i$ is the number of problems solved by the $i$-th team, $P_i$ is the penalty of the $i$-th team, and $U_i$ is a numerical representation of the university of the $i$-th team.
$0 \leq S_i \leq 10$, $0 \leq P_i \leq 10^6, 1 \leq U_i \leq 10^5$
$P_i, U_i$ are integers
For any two distinct integers $i, j$, the pairs $(S_i, P_i)$ and $(S_j, P_j)$ are never identical

Output


Output the selected $K$ teams, 0-indexed, one per line. The $K$ teams must be output in the order in which they were selected (see the samples for details). Print a newline at the end.

Sample

Sample 1
Input
5 3
3 100 1
4 200 1
4 300 1
3 150 2
2 50 2
Output
1
2
3


First, we select the 1st team.
The teams that solved the most problems are teams 1 and 2. Both are from the same university, so their "teams from the same university selected so far" are equal. Team 1 has the smaller penalty, so 1 is selected first.
Next, we select the 2nd team.
Among the teams not yet selected, the only team that solved the most problems is team 2. So team 2 is selected next.
Finally, we select the 3rd team.
Among the teams not yet selected, the teams that solved the most problems are teams 0 and 3. University 1 already has 2 teams selected, but University 2 has no team selected yet, so team 3 is selected here.
Therefore, outputting the $K$ teams in the order of selection gives 1 2 3.

Sample 2
Input
3 2
4 100 1
5 300 2
3 100 2
Output
1
0


Note that the teams must be output in the order in which they were selected.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。