[Solution] Narrow road Codeforces Solution VK Cup
Column fromscooter rides on a narrow one-way road to point B. The scooters are numbered fromto. For every scooterit is known that the current distance from it to point B is equal tometers. Whereinin particular scooteris closest to point B, and the scooter - farthest.
Scooter with numbermoves towards point B with a speedmeters per second (that is, the closer the scooter in the convoy is to point B, the slower it goes). Since the road is narrow, the scooters cannot overtake each other. Moreover, neighboring scooters in a column must keep a distance of at leastmeter. Therefore, when a faster scooter catches up with a slower one, the faster one has to go further at the speed of the slower one, and at a distance ofmeter from him.
Determine how far each scooter will be to point B in exactly one second.
The first line contains one integer () is the number of scooters in the column.
ATth of the followingrows given one integer(; ) — current distance from the scooterto point B in meters.
Bring outintegers — distances from scootersto point B in meters in one second.
In the first test, the scooters do not interfere with each other so far, so each scooteradvances onmeters towards point B.
In the second test, the scooters have already lined up in a column at a distancemeter apart and forced to ride at the speed of the slowest scooter with the number.
No comments:
Post a Comment