Plane Fuel
View as PDFAn 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 , the plane is unsafe to fly.
Determine whether the plane should be grounded.
Input Specification
The first integer,
, represents the number of hours of the flight.
The second integer,
, represents the largest total difference that is considered safe.
Each of the next lines contains two integers,
and
, the fuel taken in by the first and second engines during the
-th hour.
Output Specification
Output GROUND if, after any hour, the absolute difference between the two engines' running totals is strictly greater than . 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