GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday, 14 December 2022

[Solution] Narrow road Codeforces Solution VK Cup



A. Narrow road
test time limit
2 seconds
memory limit per test
512 megabytes
input
standard input
conclusion
standard output

Column fromnscooter rides on a narrow one-way road to point B. The scooters are numbered from1tonFor every scooteriit is known that the current distance from it to point B is equal toaimeters. Whereina1<a2<<anin particular scooter1is closest to point B, and the scootern - farthest.

Scooter with numberimoves towards point B with a speedimeters 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 least1meter. 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 of1meter from him.

Determine how far each scooter will be to point B in exactly one second.

Input data

The first line contains one integern (1n100) is the number of scooters in the column.

ATith of the followingnrows given one integerai(1ai1000a1<a2<<an) — current distance from the scooterito point B in meters.

Output

Bring outnintegers — distances from scooters1,2,,nto point B in meters in one second.


Note

In the first test, the scooters do not interfere with each other so far, so each scooteriadvances onimeters towards point B.

In the second test, the scooters have already lined up in a column at a distance1meter apart and forced to ride at the speed of the slowest scooter with the number1.

No comments:

Post a Comment