結果

問題 No.70 睡眠の重要性!
ユーザー michonz4michonz4
提出日時 2019-05-23 17:03:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 469 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 55,764 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 11:30:33
合計ジャッジ時間 882 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%d:%d %d:%d", &H, &M, &h, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>

using namespace std;

int main() {
  int n, sumH=0, sumM=0;
  cin >> n;
  for (int i=0; i<n; i++) {
    int H, M, h, m;
    scanf("%d:%d %d:%d", &H, &M, &h, &m);
    if (H>h) {
      sumH+=24-(H+1)+h;
      sumM+=60-M+m;
    } else if (H<h) {
      sumH+=h-H-1;
      sumM+=60-M+m;
    } else {
      if (M<m) {
        sumM+=m-M;
      } else {
        sumH+=23;
        sumM+=60-M;
      }
    }
  }

  cout << sumH*60+sumM << endl;
  return 0;
}
0