Time limit
2s
Memory limit
128 MB
Dongho is a student at World High School. He took N exams. On the i-th exam, his score is T_i and the total possible score is P_i.
The grade over a set of exams is the sum of their T_i values divided by the sum of their P_i values. For example, if the scores are 1/2, 5/9, 3/8, 4/10, and 1/3, the overall grade is (1+5+3+4+1)/(2+9+8+10+3) = 14/32 ≈ 0.44.
Dongho's homeroom teacher wants to improve his grade a little by excluding the D exams with the smallest percentages T_i/P_i among all N exams, then computing the grade from the remaining N-D exams. In the example above, when D=1, the smallest percentage is 1/3, so it is excluded and the grade becomes (1+5+3+4)/(2+9+8+10) = 13/29 ≈ 0.45.
Dongho argues that if exactly D exams may be excluded, excluding the smallest percentages is not always optimal. In the same example, when D=1, excluding 3/8 instead of 1/3 gives 11/24 ≈ 0.46, which is higher.
Given the exam scores, write a program that finds every D for which excluding some other D exams can make the grade strictly higher than excluding the D exams with the smallest percentages.
The first line contains the number of exams N. (1 ≤ N ≤ 50,000)
Each of the next N lines contains two integers T_i and P_i, the score and total possible score of one exam. (0 ≤ T_i ≤ P_i ≤ 40,000, 0 < P_i)
Print K, the number of values D that satisfy the condition, on the first line. (0 ≤ K ≤ N)
Then print those K values of D in increasing order, one per line.