There are n gas stations numbered from 1 to n on a ring road (you can travel between gas station i and i+1, as well as between gas station 1 and n). You need to start at any gas station, travel through all the gas stations either clockwise or counterclockwise, and return to the starting point. Initially, your vehicle has no fuel. At gas station i, you can refuel pi liters of gasoline, and each liter allows you to travel 1 kilometer. For each gas station, determine if it is possible to start at that station and complete the journey.
TAK
if it is possible to start at station i and complete the journey, otherwise print NIE
.Input:
5
3 1
1 2
5 2
0 1
5 4
Output:
TAK
NIE
TAK
NIE
TAK
Nearest position | |
Subarray minimum | |
Peak Product | |
Histogram | |
Maximum subsequence value | |
Deleting digits | |
Electric poles | |
Planting flowers | |
Ring road | |
Prefix minimum | |
Knee surgery |