結果

問題 No.70 睡眠の重要性!
コンテスト
ユーザー maicune
提出日時 2019-08-21 21:55:25
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 582 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,049 ms
コンパイル使用メモリ 182,540 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-26 00:47:46
合計ジャッジ時間 1,823 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:21:12: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   21 |         ans+=tb-ta;
      |         ~~~^~~~~~~
main.cpp:4:11: note: 'ans' was declared here
    4 |     int n,ans;
      |           ^~~

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,ans;
    cin>>n;
    vector<vector<int>> a(n),b(n);
    for(int i=0;i<n;++i){
        string s,t,tmp;
        cin>>s>>t;
        istringstream ss(s),st(t);
        while(getline(ss,tmp,':')){
            a[i].emplace_back(stoi(tmp));
        }
        while(getline(st,tmp,':')){
            b[i].emplace_back(stoi(tmp));
        }
    }
    for(int i=0;i<n;++i){
        int ta=60*a[i].front()+a[i].back(),tb=60*b[i].front()+b[i].back();
        if(ta>tb)tb+=60*24;
        ans+=tb-ta;
    }
    cout<<ans<<endl;
}
0