#C7362. Taco: Ranking Participants in a Coding Competition
Taco: Ranking Participants in a Coding Competition
Taco: Ranking Participants in a Coding Competition
In this problem, you are given a series of submissions made by participants in a coding competition. Each submission consists of a time t, a participant id p, and a score s. Your task is to rank the participants based on their best performance.
The ranking criteria are as follows:
- A participant's best score is the highest score they achieved in any submission.
- If two participants have the same best score, the participant whose best score was achieved at an earlier time is ranked higher.
Formally, if participant i has a best score \( S_i \) achieved at time \( T_i \), and participant j has a best score \( S_j \) achieved at time \( T_j \), then participant i is ranked higher than participant j if either
\( S_i > S_j \) or \( S_i = S_j \) and \( T_i < T_j \).
You need to print the ranking as a sequence of participant ids ordered from highest rank to lowest rank.
inputFormat
The first line contains an integer n which represents the number of submissions.
Each of the following n lines contains three integers t, p, and s separated by spaces, where:
- t is the time of the submission.
- p is the participant id.
- s is the score of the submission.
You may assume that submissions are given in chronological order.
outputFormat
Output a single line containing the participant ids in order of their ranking, separated by a space. There should be no extra spaces at the beginning or end of the line.
## sample5
1 1 100
2 2 200
3 1 150
4 3 200
5 2 250
2 3 1