| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 40 | 33 | 31 | 86.111% |
In the recent National Science Olympiad, a new tie-breaker rule was implemented using time penalties measured in minutes.
The olympiad ran for two days and participated in by $N$ contestants. The $i$-th participant, whose name is $S_i$, received $A_i$ points with time penalty $B_i$ on the first day, and received $C_i$ points with time penalty $D_i$ on the second day.
The contestants are ranked based on their total points from both days, with higher points being ranked higher. Contestants who receive the same total points will be ranked based on the sum of their time penalties from both days, with lower penalties being ranked higher. If there are still ties, they will be ranked based on their name, with the lexicographically smaller name being ranked higher.
Your task is to output the name of the contestants ranked from highest to lowest.
The first line contains an integer $N$ ($1 \le N \le 100$). Each of the next $N$ lines contains a string $S_i$ ($1 \leq |S_i| \leq 10$), containing uppercase English alphabets, followed by four integers $A_i$, $B_i$, $C_i$, and $D_i$ ($0 \le A_i, B_i, C_i, D_i \le 300$) representing their points and penalties from both days.
Output $N$ lines, each containing the name of the contestants, in order from the higher-ranked to the lower-ranked.
5 ANDI 200 120 150 130 BUDI 170 70 180 170 CUPU 0 300 0 300 DEWA 300 0 300 0 MALANG 0 300 0 300
DEWA BUDI ANDI CUPU MALANG
Explanation of Sample 1: Let us consider the ranks between ANDI and BUDI. Both ANDI and BUDI received the same total points, which is $350$, but BUDI is ranked higher because BUDI's time penalty (which is $240$) is lower than ANDI's (which is $250$).
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2025 A번