Plane Fuel

View as PDF

Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 39M

Author:
Problem type

An aeronautics engineer suspects that a plane is not sending fuel evenly to both engines. During a flight, he records how much fuel each engine takes in during every hour of the flight.

After each hour, the engineer compares the total fuel the first engine has taken in so far with the total fuel the second engine has taken in so far. If at any point these two totals differ by more than D, the plane is unsafe to fly.

Determine whether the plane should be grounded.

Input Specification

The first integer, N (1 \le N \le 10^5), represents the number of hours of the flight.
The second integer, D (1 \le D \le 10^9), represents the largest total difference that is considered safe.

Each of the next N lines contains two integers, a_i and b_i (0 \le a_i, b_i \le 10^4), the fuel taken in by the first and second engines during the i-th hour.

Output Specification

Output GROUND if, after any hour, the absolute difference between the two engines' running totals is strictly greater than D. Otherwise, output FLY.

Sample Input 1

3 10
10 0
0 10
3 3

Sample Output 1

FLY

Sample Input 2

4 5
6 0
0 6
2 2
1 1

Sample Output 2

GROUND


Comments

There are no comments at the moment.