結果

問題 No.70 睡眠の重要性!
ユーザー Yug_min_nullYug_min_null
提出日時 2021-09-05 05:59:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 853 bytes
コンパイル時間 1,750 ms
コンパイル使用メモリ 186,052 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 14:00:58
合計ジャッジ時間 2,391 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N; cin >> N;
  int ans = 0;
  for(int i = 0; i < N; i++){
    string S, T; cin >> S >> T;
    S += ":", T += ":";
    int s = 0, s1 = 0, s2 = 0, t = 0, t1 = 0, t2 = 0;
    for(int j = 0; j < (int)S.size(); j++){
      if(S[j] != ':'){
        if(s == 0){
          s1 *= 10;
          s1 += S[j]-48;
        }else{
          s2 *= 10;
          s2 += S[j]-48;
        }
      }else{
        s++;
      }
    }
    for(int j = 0; j < (int)T.size(); j++){
      if(T[j] != ':'){
        if(t == 0){
          t1 *= 10;
          t1 += T[j]-48;
        }else{
          t2 *= 10;
          t2 += T[j]-48;
        }
      }else{
        t++;
      }
    }
    int s3 = s1*60+s2, t3 = t1*60+t2;
    if(s3 > t3) t3 += 1440;
    ans += t3-s3;
  }
  cout << ans << endl;
}
0