#P2583. [ICPC 2003 WF] 地铁间谍

[ICPC 2003 WF] 地铁间谍

Output Format

For each dataset, print one line Case Number N:\text{\texttt{Case Number }\textit{N}\texttt{:}} (where NN starts from 11) followed by an integer denoting the minimal total waiting time, or the word impossible\verb!impossible! if Maria cannot accomplish the task.

See the sample output.

4
55
5 10 15
4
0 5 10 20
4
0 5 10 15
4
18
1 2 3
5
0 3 6 10 12
6
0 3 5 7 12 15
2
30
20
1
20
7
1 3 5 7 11 13 17
0

Case Number 1: 5
Case Number 2: 0
Case Number 3: impossible

Hint

Explanation for Sample 1:

She boards at minute 00, gets off at station 33, immediately takes the train that left at minute 00 and departs at minute 1515 to go back, gets to station 22, immediately takes the train that started at minute 2020 and departs at minute 2525 to the terminal, arrives at minute 5050, and then needs to wait 55 minutes.

Translated by ChatGPT 5