PDP-18(2006) - Phase C' - 1 (cyclotron)

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 4.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
C, C++, Java, Pascal, Python

CYCLOTRON

Participants in the camp of the 18th Hellenic Student Programming Contest (EPY 2005-06) visited the new Cyclotron for Elementary Particle Acceleration (CEPA) in Thessaloniki. This accelerator includes N chambers for particle entry. At the entrance of each chamber, particles receive energy E^{in}_{(N)} (where N is the chamber number). During their trajectory to the next chamber, the particles spend energy equivalent to a potential barrier E^{out}_{(N)} that they must "overcome". If E^{in}_{(N)} \ge E^{out}_{(N)}, the particle will reach the next chamber (N + 1), where it will receive energy E^{in}_{(N+1)}. Therefore, the total energy of the particle in chamber N + 1 (assuming it entered at chamber N) will be: (E^{in}_{(N)} - E^{out}_{(N)} ) + E^{in}_{(N+1)}.

You are asked to develop a program in one of the IOI languages that determines the first (with the smallest number) chamber from which, if the particle enters, it will complete a full circular trajectory within the accelerator.

INPUT DATA

The file cyclotron.in on the first line contains an integer indicating the number of entry chambers N, where: (10 \le N \le 2\,000\,000). In the next N lines, two integers X and Y separated by a space (0 \le X, Y \le 1\,000) are given. The first number on each line, (X), provides the energy (in eV) provided to the particle upon entry into the chamber, and the second number, (Y), gives the energy spent by the particle until the next chamber.

OUTPUT DATA

The file cyclotron.out consists of an integer corresponding to the chamber number from which the particle must start in order to complete a full circular trajectory within the accelerator. If there is no suitable entry chamber, the number 0 is returned.

Example of Input - Output Data

STDIN (cyclotron.in)

10
50 100
120 100
90 100
140 100
90 90
90 90
90 90
90 90
90 90
90 90

STDOUT (cyclotron.out)

2

Maximum execution time for each test: 4 sec.


Comments

There are no comments at the moment.