結果

問題 No.70 睡眠の重要性!
ユーザー momoyuumomoyuu
提出日時 2022-08-17 01:55:02
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,173 bytes
コンパイル時間 3,444 ms
コンパイル使用メモリ 275,696 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 19:22:40
合計ジャッジ時間 4,072 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int calc(std::string, std::string)':
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;
      |         ^~
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;
      |         ^~

ソースコード

diff #

#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;
}
0