문제
Problem 3: Airplane Boarding [Travis Hance]
FJ's cows have decided to take a vacation, and have miraculously managed to find an airline willing to sell them tickets. When they arrive at the airport and start boarding their plane, they face an interesting problem, however.
The airplane has N seats, which we model as the points x=1 through x=N on the number line. All N cows
At each time step, each cow takes a step to the right if she can. When cow i reaches her seat
How long will it take for all the cows to sit down?
The sum of
PROBLEM NAME: boarding
입력
INPUT FORMAT:
* Line 1: A single integer, N.
* Lines
출력
OUTPUT FORMAT:
* Line 1: A single line indicating the amount of time it takes to seat all cows.
예제1
3
2 5
3 10
1 5
19
INPUT DETAILS:
Initially, the cows are situated like this:
cows -> 123
123 <- seats
with cow 1 trying to get to seat 2, cow 2 trying to get to seat 3, and cow 3 trying to get to seat 1.
OUTPUT DETAILS:
After one step, they will all move 1 to the right and cow 3 will reach her seat:
123
123
Cow 3 takes 5 seconds to sit down, at which point she effectively disappears.
12
123
It takes 3 more seconds for cows 1 and 2 to reach their desired seats:
12
123
It takes 5 seconds for cow 1 to sit down and 10 seconds for cow 2 to sit down, so that's 10 seconds total. In total this took