結果
| 問題 |
No.70 睡眠の重要性!
|
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-01 12:31:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,100 bytes |
| コンパイル時間 | 5,586 ms |
| コンパイル使用メモリ | 221,124 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 07:04:28 |
| 合計ジャッジ時間 | 6,224 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
ソースコード
// 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;
}
kichirb3