結果

問題 No.70 睡眠の重要性!
ユーザー kuisibakuisiba
提出日時 2016-03-30 14:44:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 65,336 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-10 06:29:59
合計ジャッジ時間 1,127 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

vector<string> conv(string s) {
    istringstream iss(s); string tmp; vector<string> vec;
    while (getline(iss, tmp, ':')) vec.push_back(tmp);
    return vec;
}

int func(string s) {
    vector<string> vec;
    vec = conv(s);
    int a = 0, b = 0;
    a = stoi(vec.at(0));
    b = stoi(vec.at(1));
    return a * 60 + b;
}

int main() {
    int n;
    cin >> n;
    int a = 0, b = 0, ans = 0;
    string x, y;

    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        a = func(x);
        b = func(y);
        ans += ((1440 + b - a) % 1440);
    }
    cout << ans <<endl;
    return 0;
}
0