結果

問題 No.70 睡眠の重要性!
ユーザー Yut176Yut176
提出日時 2016-10-07 23:00:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,233 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 73,576 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 15:05:37
合計ジャッジ時間 1,499 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;

int main(){

  int n;
  cin >> n;
  int ans = 0;
  for(int i=0; i<n; i++){
    string a, b;
    cin >> a >> b;

    bool fl = false;
    int s = 0, g = 0;
    if( a[1] == ':' ){
      if( a.size() == 3 ){
        s += (a[0]-'0') * 60 + (a[2]-'0');
      }else{
        s += (a[0]-'0') * 60 + (a[2]-'0') * 10 + (a[3]-'0');
      }
    }else{
      if( a.size() == 4 ){
        s += (a[0]-'0') * 60 * 10 + (a[1]-'0') * 60 + (a[3]-'0');
      }else{
        s += (a[0]-'0') * 60 * 10 + (a[1]-'0') * 60 + (a[3]-'0') * 10 + (a[4]-'0');
      }
    }

    if( b[1] == ':' ){
      if( b.size() == 3 ){
        g += (b[0]-'0') * 60 + (b[2]-'0');
      }else{
        g += (b[0]-'0') * 60 + (b[2]-'0') * 10 + (b[3]-'0');
      }
    }else{
      if( b.size() == 4 ){
        g += (b[0]-'0') * 60 * 10 + (b[1]-'0') * 60 + (b[3]-'0');
      }else{
        g += (b[0]-'0') * 60 * 10 + (b[1]-'0') * 60 + (b[3]-'0') * 10 + (b[4]-'0');
      }
    }
    if( s > g ){
      g += 1440;
    }
    ans += (g - s);

  }
  cout << ans << endl;

  return 0;
}
0