#K7956. Participant Ranking
Participant Ranking
Participant Ranking
In this contest problem, you are given a series of submissions from various participants. Each submission is characterized by three integers: a participant identifier, a score, and a submission time. Your task is to rank the participants based on the following rules:
- A participant's best performance is determined by the highest score they achieved.
- If a participant has multiple submissions with the same highest score, the submission with the earliest time is considered.
- The ranking is then determined in descending order of the best score. In case of a tie in the best score, the participant with the lower (earlier) submission time ranks higher.
Formally, let ( s_i ) be the best score of the ( i\text{-th} ) participant and ( t_i ) be the earliest time at which this score was achieved. Then, one participant ( i ) is ranked higher than another participant ( j ) if either ( s_i > s_j ) or ( s_i = s_j ) and ( t_i < t_j ).
Participants with no submissions are not included in the ranking. Your solution should read input from standard input (stdin) and output the ranked list of participant IDs to standard output (stdout) as a space-separated string.
inputFormat
The first line of input contains an integer ( n ), which indicates the number of submissions. Each of the following ( n ) lines contains three integers separated by spaces: the participant ID, the score of the submission, and the submission time.
For example:
6 1 50 5 2 80 1 1 80 2 3 90 10 2 85 3 4 70 4
outputFormat
Output a single line containing the participant IDs in ranked order (1-indexed ranking is implicit in the order), separated by a single space. If there are no submissions, output an empty line.## sample
6
1 50 5
2 80 1
1 80 2
3 90 10
2 85 3
4 70 4
3 2 1 4