結果

問題 No.70 睡眠の重要性!
ユーザー kichirb3kichirb3
提出日時 2018-03-01 12:31:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,100 bytes
コンパイル時間 5,162 ms
コンパイル使用メモリ 219,324 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 20:51:09
合計ジャッジ時間 5,797 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// No.70 睡眠の重要性!
// https://yukicoder.me/problems/no/70
//
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <regex>
using namespace std;

vector<string> split_input();

int main() {
    unsigned int N;
    cin >> N;

    unsigned int slept = 0;
    vector<string> st;
    for (auto i = 0; i < N; ++i) {
        st = split_input();
        int start_time = stoi(st[0])*60 + stoi(st[1]);
        st = split_input();
        int end_time = stoi(st[0])*60 + stoi(st[1]);
        if (start_time > end_time)
            end_time += 24 * 60;
        slept += (end_time - start_time);
    }

    cout << slept << endl;
}

vector<string> split_input()
{
    // :文字区切りのデータを分割しその結果を返す。
    vector<string> res;
    string input_txt;
    cin >> input_txt;
    regex rx(R"(:)");
    sregex_token_iterator it(input_txt.begin(), input_txt.end(), rx, -1);
    sregex_token_iterator end;
    while (it != end) {
        if (*it != "")
            res.push_back(*it++);
        else
            it++;
    }
    return res;
}

0