結果
| 問題 | No.70 睡眠の重要性! | 
| コンテスト | |
| ユーザー |  f843nmfwisfeuw | 
| 提出日時 | 2020-07-29 20:39:50 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 1,594 bytes | 
| コンパイル時間 | 954 ms | 
| コンパイル使用メモリ | 98,852 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-30 03:28:39 | 
| 合計ジャッジ時間 | 1,389 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 6 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
using namespace std;
// 00:00からの差が何分かを考える
// 日またぎ
// 起きた時間 <= 寝た時間
// 日またぎしない
// 1日は24*60分
// 起きた時間 >= 寝た時間
int asMinute(int h, int m) {
    return h * 60 + m;
}
vector<string> split(string s, const string &delimiter) {
    size_t pos_start = 0, pos_end, delim_len = delimiter.length();
    string token;
    vector<string> res;
    while ((pos_end = s.find(delimiter, pos_start)) != string::npos) {
        token = s.substr(pos_start, pos_end - pos_start);
        pos_start = pos_end + delim_len;
        res.push_back(token);
    }
    res.push_back(s.substr(pos_start));
    return res;
}
int main() {
    int N;
    cin >> N;
    int result = 0;
    for (int i = 0; i < N; ++i) {
        string S1, S2;
        cin >> S1 >> S2;
        vector<string> ss1 = split(S1, ":");
        vector<string> ss2 = split(S2, ":");
        int H = stoi(ss1[0]);
        int M = stoi(ss1[1]);
        int h = stoi(ss2[0]);
        int m = stoi(ss2[1]);
        int sleep = asMinute(H, M);
        int wakeUp = asMinute(h, m);
        if (sleep < wakeUp) {
            result += (wakeUp - sleep);
        } else if (wakeUp == sleep) {
            continue;
        } else {
            result += ((wakeUp + 24 * 60) - sleep);
        }
    }
    cout << result << endl;
    return 0;
}
            
            
            
        