#abc308c. C - Standings

C - Standings

Score : 300300 points

问题描述

设有 NN 名编号为 11NN 的人,他们各自掷了多次硬币。已知第 ii 个人掷硬币的结果为正面朝上 AiA_i 次,反面朝上 BiB_i 次。

定义第 ii 个人的掷硬币 成功率AiAi+Bi\displaystyle\frac{A_i}{A_i+B_i}。请按照成功率从高到低对编号为 1,,N1,\ldots,N 的人进行排序,如果成功率相同,则按照其编号从小到大的顺序进行排列。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

NN people numbered 11 through NN tossed a coin several times. We know that person ii's tosses resulted in AiA_i heads and BiB_i tails.

Person ii's success rate of the tosses is defined by AiAi+Bi\displaystyle\frac{A_i}{A_i+B_i}. Sort people 1,,N1,\ldots,N in descending order of their success rates, with ties broken in ascending order of their assigned numbers.

Constraints

  • 2N2×1052\leq N \leq 2\times 10^5
  • 0Ai,Bi1090\leq A_i, B_i\leq 10^9
  • Ai+Bi1A_i+B_i \geq 1
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 B1B_1

\vdots

ANA_N BNB_N

Output

Print the numbers of people 1,,N1,\ldots,N in descending order of their success rates, with ties broken in ascending order of their assigned numbers.

Sample Input 1

3
1 3
3 1
2 2

Sample Output 1

2 3 1

Person 11's success rate is 0.250.25, person 22's is 0.750.75, and person 33's is 0.50.5.

Sort them in descending order of their success rates to obtain the order in Sample Output.

Sample Input 2

2
1 3
2 6

Sample Output 2

1 2

Note that person 11 and 22 should be printed in ascending order of their numbers, as they have the same success rates.

Sample Input 3

4
999999999 1000000000
333333333 999999999
1000000000 999999997
999999998 1000000000

Sample Output 3

3 1 4 2

update @ 2024/3/10 08:43:50