No.70 The Importance of Sleep!
Problem Statement
For his health, Taro keeps a daily record of the times he went to sleep and woke up.
Given a list of the times he went to sleep and woke up as input,
output the total sleep time.
Assume that Taro never sleeps continuously for \(24\) hours or more in \(1\) session.
In Taro's world, \(1\) day consists of \(24\) hours, and \(1\) hour consists of \(60\) minutes.
Input
\(N\) \(H_1:M_1\ h_1:m_1\) \(H_2:M_2\ h_2:m_2\) \(\dots\) \(H_i:M_i\ h_i:m_i\) \(\dots\) \(H_N:M_N\ h_N:m_N\)
Line \(1\) contains an integer \(N\ (1 \leq N \leq 30)\), the number of records.
The following \(N\) lines each contain a record of the time he went to sleep and the time he woke up for \(1\) sleep session.
The time he went to sleep and the time he woke up are not the same.
\((0 \leq H_i,h_i \leq 23,\ 0 \leq M_i,m_i \leq 59)\)
Each record is given in the format "H:M h:m", where the hour and minute are separated by a half-width colon,
and the time he went to sleep (\(H\) o'clock \(M\) minutes) and the time he woke up (\(h\) o'clock \(m\) minutes) are separated by a half-width space.
Output
Output the total sleep time in minutes.
Print a newline at the end.
Sample
Sample 1
Input
3 22:24 5:9 22:46 5:37 1:11 7:11
Output
1176
The sleep sessions last \(6\) hours \(45\) minutes / \(6\) hours \(51\) minutes / \(6\) hours \(0\) minutes respectively, for a total of \(19\) hours \(36\) minutes.
Converted to minutes, this is \(1176\) minutes.
Sample 2
Input
5 22:30 4:30 22:46 4:46 1:17 7:26 0:38 7:0 23:49 7:41
Output
1943
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。