問題一覧 > 通常問題

No.70 The Importance of Sleep!

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 621
作問者 : なお
お気に入りにしたユーザー ProblemId : 126 / 自分の提出
問題文最終更新日: 2026-10-11 21:48:36
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 54 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。