시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 1 | 1 | 1 | 100.000% |
You are a very busy person, with a lot of important meetings. Today, you have a meeting for which it is insanely important to arrive at the agreed time.
Luckily you live in Zürich, which features a large network of extremely punctual trams. Each tram line travels from one place to another at regular intervals, always taking the same time from departure to arrival. It is very easy to change trams, and we assume that it takes no time to change to another tram if both are at a stop at the same time. This means that if a tram arrives at its destination at exactly time $t$ and another tram departs from the same place at time $t$ (or later), you will have enough time to change tram.
You are currently working in your hotel room before the meeting. Since you are a very busy person, you would like to leave your hotel at the latest possible time possible while still ariving to the meeting on time. When do you need to leave for your meeting?
The input consists of:
The stops are numbered between $0$ and $n - 1$. Your hotel is located at stop $0$, and the meeting is at stop $n - 1$.
Output the latest time at which you can leave the hotel while arriving to your meeting on time, in seconds from now. If you can not make it to your meeting on time, output impossible
instead.
2 1 10 0 1 1 2 6
3
2 1 5 0 1 1 1 5
impossible
Contest > Swedish Coding Cup > LTH Challenge 2017 A번