/
Time Limit: 2 sec / Memory Limit: 1024 MiB
問題文
N 人の生徒が期末試験を受けました。 生徒には番号が振られており、1 番から N 番までの異なる整数の番号がついています。
i 番 (1\leq i\leq N) の生徒は、英語の試験で E _ i 点、数学の試験で M _ i 点を取りました。
試験の結果を用いて、生徒の順位が決まります。 順位は以下のようにして決められます。
- 英語と数学の試験で取った点の合計がより大きい生徒はより小さい生徒より順位が高い。
- 英語と数学の試験で取った点の合計が等しいとき、数学の試験で取った点がより大きい生徒はより小さい生徒より順位が高い。
- 英語と数学の試験で取った点の合計と数学の試験で取った点のいずれも等しいとき、番号がより大きい生徒はより小さい生徒より順位が高い。
順位が高いほうから生徒の番号を出力してください。
制約
- 1\leq N\leq100
- 0\leq E _ i\leq100\ (1\leq i\leq N)
- 0\leq M _ i\leq100\ (1\leq i\leq N)
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N E _ 1 M _ 1 E _ 2 M _ 2 \vdots E _ N M _ N
出力
最も順位の高い生徒から、空白を区切りとしてすべての生徒の番号を順位の降順に出力せよ。
入力例 1
4 80 70 40 100 60 80 60 80
出力例 1
1 2 4 3
合計点数は、1 番の生徒の 150 点が最も高いです。 よって、最も順位の高い生徒は 1 番の生徒です。
他の生徒の合計点数はいずれも 140 点です。 これらの生徒のうち、2 番の生徒が取った数学の点数は 100 点で最も高いです。 よって、次に順位の高い生徒は 2 番の生徒です。
3 番の生徒と 4 番の生徒は合計点数も数学の点数も等しいです。 このとき、より番号の大きい生徒のほうが順位が上なので、次に順位の高い生徒は 4 番の生徒で、最も順位の低い生徒は 3 番の生徒です。
以上より、1 2 4 3 を出力してください。
入力例 2
1 1 1
出力例 2
1
生徒が 1 人しかいない場合もあります。
入力例 3
12 72 7 54 25 97 48 37 47 34 54 4 16 62 1 59 22 99 73 34 75 6 45 82 84
出力例 3
9 12 3 10 5 4 8 2 1 7 11 6
Problem Statement
N students took a final exam. Each student has a student ID, which is a unique integer between 1 and N.
The student with ID i (1\leq i\leq N) marked E _ i points in English and M _ i points in math.
The students' ranks are determined based on their scores by the following criteria:
- Those with higher total (English and math) scores rank higher.
- Among those with the same total score, those with higher math scores rank higher.
- Among those with the same total score and math score, those with larger IDs rank higher.
Print the student IDs in the order of their ranks.
Constraints
- 1\leq N\leq100
- 0\leq E _ i\leq100\ (1\leq i\leq N)
- 0\leq M _ i\leq100\ (1\leq i\leq N)
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N E _ 1 M _ 1 E _ 2 M _ 2 \vdots E _ N M _ N
Output
Print all the student IDs, separated by spaces, in order of their ranks, with higher-ranked students coming first.
Sample Input 1
4 80 70 40 100 60 80 60 80
Sample Output 1
1 2 4 3
Student 1 marked the highest total score of 150 points. Thus, student 1 ranks highest.
The other students marked the same total score of 140 points. Among them, student 2 marked the highest math score of 100 points. Thus, student 2 ranks the next.
Student 3 and 4 marked the same total and math scores. Among them, those with larger IDs rank higher. Thus, student 4 ranks the next, and student 3 ranks lowest.
Hence, 1 2 4 3 should be printed.
Sample Input 2
1 1 1
Sample Output 2
1
There may be only one student.
Sample Input 3
12 72 7 54 25 97 48 37 47 34 54 4 16 62 1 59 22 99 73 34 75 6 45 82 84
Sample Output 3
9 12 3 10 5 4 8 2 1 7 11 6