結果

問題 No.70 睡眠の重要性!
ユーザー MaboyMaboy
提出日時 2021-06-03 16:07:37
言語 Swift
(5.10.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 539 bytes
コンパイル時間 9,965 ms
コンパイル使用メモリ 129,176 KB
実行使用メモリ 9,216 KB
最終ジャッジ日時 2024-04-28 11:02:40
合計ジャッジ時間 10,990 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
9,216 KB
testcase_01 AC 9 ms
9,216 KB
testcase_02 AC 9 ms
9,088 KB
testcase_03 AC 8 ms
9,088 KB
testcase_04 AC 9 ms
9,088 KB
testcase_05 AC 9 ms
9,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func time2min(time: String) -> Int {
    let hm = time.split(separator: ":")
    let h = Int(hm[0])
    let m = Int(hm[1])
    return (h! * 60 + m!)
}

let N = Int(readLine()!)
var totalMinute = 0

for _ in 1...N!{
    let times = readLine()!.split(separator: " ")
    let time1 = String(times[0])
    let time2 = String(times[1])
    let minute1 = time2min(time: time1)
    let minute2 = time2min(time: time2)
    let sleepMinute = minute2 - minute1
    totalMinute += (sleepMinute + (sleepMinute < 0 ? 24 * 60 : 0))
}
print(totalMinute)
0