Swimming pool

(The original statement in Catalan has some private jokes. This English
version goes straight to the point of the problem.)

There is a swimming pool with some free slots of time. There are two
rules:

- A slot can only be used from its beginning.

- If a slot is used, even if partially, you must wait for at least one
  hour from the end of the slot before you can use another slot.

Input

Input consists of several cases. Every case begins with the number of
slots n, followed by n pairs of triplets h₁:m₁:s₁ h₂:m₂:s₂, which
indicate that there is a slot from h₁:m₁:s₁ until h₂:m₂:s₂. Assume
1 ≤ n ≤ 1000, that hours are between 0 and 23, that minutes are between
0 and 59, and that h₁:m₁:s₁ is smaller than h₂:m₂:s₂. The end of input
is marked with a special case with n = 0.

Output

For every case, print the maximum number of seconds that you can swim.

Problem information

Author: Lander Ramos

Generation: 2026-01-25T10:00:27.920Z

© Jutge.org, 2006–2026.
https://jutge.org
