| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 (추가 시간 없음) | 1024 MB | 59 | 47 | 47 | 87.037% |
You are on a skiing trip in the Alps and need to take a funicular.1 However, there usually is a long queue for the funicular to bring you to the top of the mountain. Being someone who hates wasting time in the morning, you want to find the best moment to start queueing in order to minimize queueing time.
The funicular station is open for \(n\) minutes per day. A carriage transports \(c\) people at once, and one carriage leaves exactly every minute. For every minute the funicular is open today, you know the number of people arriving.
You want to arrive when the station is open, exactly at the start of a minute, like everyone else. Note that you are a sociable person and if there are other people arriving at the same minute as you, you let them go first, after which you stand in the queue.
Calculate at which minute you should arrive to have minimal waiting time, or determine that it is impossible to catch a ride today. If there are two times achieving the same minimal waiting time, give the earliest occasion.
1 A funicular is a type of cable railway system laid on a steep slope, where two counterbalanced carriages are attached to opposite ends of a haulage cable, which is looped over a pulley at the upper end of the track.
The input consists of:
If it is not possible to take the funicular today, output "impossible". Else, output the least number of minutes after opening time you should enter the queue, such that the waiting time is minimized.
5 1 5 0 0 0 0
impossible
5 4 8 6 4 2 0
0
10 10 12 11 10 9 8 7 6 5 4 3
5
ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2023 F번