結果
問題 | No.70 睡眠の重要性! |
ユーザー |
|
提出日時 | 2021-02-27 12:19:55 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 51 ms / 5,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 3,375 ms |
コンパイル使用メモリ | 76,144 KB |
実行使用メモリ | 36,932 KB |
最終ジャッジ日時 | 2024-10-02 17:24:40 |
合計ジャッジ時間 | 4,112 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class No00000070_Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int ans = 0; for(int i = 0; i < n ; i++) { String[] timeArr = br.readLine().split(" "); ans += getSleepTime(timeArr); } System.out.println(ans); } private static int getSleepTime(String[] arr) { int h1 = Integer.parseInt(arr[0].split(":")[0]); int m1 = Integer.parseInt(arr[0].split(":")[1]); int h2 = Integer.parseInt(arr[1].split(":")[0]); int m2 = Integer.parseInt(arr[1].split(":")[1]); if(m1 > m2) { h2--; m2 += 60; } if(h1 > h2) { h2 += 24; } return (h2 - h1) * 60 + (m2 - m1); } }