結果
| 問題 | No.70 睡眠の重要性! | 
| コンテスト | |
| ユーザー |  momoyuu | 
| 提出日時 | 2022-08-17 01:55:02 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,173 bytes | 
| コンパイル時間 | 3,227 ms | 
| コンパイル使用メモリ | 246,036 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-03 21:05:48 | 
| 合計ジャッジ時間 | 3,538 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 6 | 
コンパイルメッセージ
main.cpp: In function 'int calc(std::string, std::string)':
main.cpp:39:11: warning: 'hb' may be used uninitialized [-Wmaybe-uninitialized]
   39 |     count = hb - ha;
      |     ~~~~~~^~~~~~~~~
main.cpp:26:9: note: 'hb' was declared here
   26 |     int hb,sb;
      |         ^~
main.cpp:39:11: warning: 'ha' may be used uninitialized [-Wmaybe-uninitialized]
   39 |     count = hb - ha;
      |     ~~~~~~^~~~~~~~~
main.cpp:13:9: note: 'ha' was declared here
   13 |     int ha,sa;
      |         ^~
            
            ソースコード
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,a,b) for (int i = a; i < b; i++)
#define irep(i,a,b) for (int i = a; i > b; i--)
#define print(n) cout << n << endl
#define rup(a,b) (a+b-1)/b
using namespace std;
int calc(string a,string b){
    int now = 0;
    int ha,sa;
    bool p = false;
    rep(i,0,a.size()){
        if (a[i]==':'){
            p = true;
            ha = now;
            now = 0;
            continue;
        }
        now *= 10;
        now += int(a[i]-'0');
    }
    sa = now;
    int hb,sb;
    now = 0;
    rep(i,0,b.size()){
        if(b[i]==':'){
            hb = now;
            now = 0;
            continue;
        }
        now *= 10;
        now += int(b[i]-'0');
    }
    sb = now;
    int count;
    count = hb - ha;
    if (count < 0) count += 24;
    count *= 60;
    count += sb - sa;
    if (count<0) count += 24*60;
    return count;
}
int main(){
    cout << fixed << setprecision(15);
    
    int n;
    cin >> n;
    int count = 0;
    rep(i,0,n){
        string a,b;
        cin>>a>>b;
        count += calc(a,b);
    }
    print(count);
    
    //system("pause");
    return 0;
}
            
            
            
        