Observers
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Mr. Petro is a very responsible citizen. In this year’s elections, he was an observer at polling station No. 47 and closely monitored the voting process of his fellow citizens. At the same time, he meticulously recorded the time when each voter arrived at the station and left it, so that later, by analyzing his notes, he could find any potential violations.
Mr. Petro analyzed the data for a long time and discovered one interesting fact. During the elections, it often happened that there was not a single voter at the station. Petro, as a responsible citizen, suspected that terrible violations of the electoral process could have occurred during this time, and wanted to figure out what was what. The first thing that interested him was the total time when there was not a single voter at the polling station.
Mr. Petro turned to you for help. Your task: given Mr. Petro’s information about the arrival and departure times of the voters, determine the total time when there was not a single voter at the polling station.
Input
The first line specifies a single natural number \(n\) — the number of voters who came to vote.
The next \(n\) lines specify
information about the voters, one per line. Each line contains 6
integers: \(h_1\), \(m_1\), \(s_1\), \(h_2\), \(m_2\), \(s_2\) — the hour, minute, and second at the
beginning of which the voter arrived, and respectively, the hour,
minute, and second at the beginning of which the voter left. These
numbers will be given with leading zeros so that the length of each
number is equal to 2, i.e., 09 47 04 instead of
9 47 4.
It is guaranteed that each voter’s stay interval at the station specifies a valid time interval (the voter left the station after arriving at it) between eight in the morning and eight in the evening.
Output
In a single line, output a single integer — the number of seconds from eight in the morning to eight in the evening during which there were no voters at the station.
Constraints
\(1 \le n \le 47474\),
\(8 \le h_1 \le h_2 \le 20\),
\(0 \le m_1, s_1, m_2, s_2 \le 59\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 4 08 30 00 09 00 00 10 00 00 18 00 00 08 00 00 08 10 00 08 05 00 08 20 00 | 11400 |
Notes
Time intervals when there was not a single voter at the polling station:
08:20:00—08:30:0009:00:00—10:00:0018:00:00—20:00:00
Total 11400 seconds.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|