結果
| 問題 |
No.70 睡眠の重要性!
|
| コンテスト | |
| ユーザー |
ajiruajiru
|
| 提出日時 | 2020-02-05 00:38:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 751 bytes |
| コンパイル時間 | 630 ms |
| コンパイル使用メモリ | 68,208 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-21 07:53:01 |
| 合計ジャッジ時間 | 1,136 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void) {
int n;
cin >> n;
string HM, hm;
int ans = 0;
for (int i = 0; i < n; ++i) {
cin >> HM >> hm;
int pos = HM.find(':');
string H = HM.substr(0, pos),
M = HM.substr(pos + 1);
pos = hm.find(':');
string h = hm.substr(0, pos),
m = hm.substr(pos + 1);
int h1 = stoi(H), m1 = stoi(M),
h2 = stoi(h), m2 = stoi(m);
if (h1 == h2) {
if (m2 >= m1) ans += m2 - m1;
else ans += 1440 - (m1 - m2);
}
else if (h2 > h1) {
ans += 60 - m1;
ans += (h2 - h1 - 1) * 60;
ans += m2;
}
else if (h1 > h2) {
ans += 60 - m1;
ans += (24 - h1 - 1) * 60;
ans += h2 * 60;
ans += m2;
}
}
cout << ans << endl;
return 0;
}
ajiruajiru