結果

問題 No.70 睡眠の重要性!
ユーザー chacoder1chacoder1
提出日時 2020-11-22 19:30:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 1,904 ms
コンパイル使用メモリ 200,140 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 23:02:06
合計ジャッジ時間 2,524 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(){
  int n;
  cin>>n;
  string t1,t2;
  int h1,m1,h2,m2;
  int sum=0;
  for(int i=0;i<n;i++){
    h1=0;m1=0;h2=0;m2=0;
    cin>>t1>>t2;
    int flag=0;
    for(int j=0;j<t1.length();j++){
      if(flag==0 && t1.at(j) !=':'){
        h1*=10;
        h1+=t1.at(j)-'0';
      }
      if(t1.at(j)==':'){
        flag++;
        continue;
      }
      if(flag==1){
        m1*=10;
        m1+=(t1.at(j)-'0');
      }
    }
    flag=0;
    for(int j=0;j<t2.length();j++){
      if(flag==0 && t2.at(j) !=':'){
        h2*=10;
        h2+=t2.at(j)-'0';
      }
      if(t2.at(j)==':'){
        flag++;
        continue;
      }
      if(flag==1){
        m2*=10;
        m2+=(t2.at(j)-'0');
      }
    }    
         
    if(h1>h2){
      sum+=((24-h1-1)*60+(60-m1)+h2*60+m2);
    }
    else{
      sum+=((h2-h1)*60+m2-m1);
    }
  }
  cout<<sum<<endl;  
  return 0;
}

0