結果
| 問題 |
No.70 睡眠の重要性!
|
| コンテスト | |
| ユーザー |
Tatsu_mr
|
| 提出日時 | 2024-10-10 23:00:15 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,031 bytes |
| コンパイル時間 | 2,816 ms |
| コンパイル使用メモリ | 246,728 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-10 23:00:19 |
| 合計ジャッジ時間 | 3,546 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:39:59: warning: 'y' may be used uninitialized [-Wmaybe-uninitialized]
39 | int c = stoi(t.substr(0, y)), d = stoi(t.substr(y + 1));
| ~~^~~
main.cpp:27:16: note: 'y' was declared here
27 | int x, y;
| ^
main.cpp:38:30: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized]
38 | int a = stoi(s.substr(0, x)), b = stoi(s.substr(x + 1));
| ~~~~~~~~^~~~~~
main.cpp:27:13: note: 'x' was declared here
27 | int x, y;
| ^
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for(long long i = 0; i < (long long)n; i++)
#define ALL(v) (v).begin(), (v).end()
#define rALL(v) (v).rbegin(), (v).rend()
using namespace std;
using lint = long long;
using ld = long double;
int main() {
int n;
cin >> n;
int ans = 0;
auto calc = [](int a, int b, int c, int d) -> int {
if (a > c || (a == c && b > d)) {
c += 24;
}
if (b > d) {
c--;
d += 60;
}
return (c - a) * 60 + (d - b);
};
while (n--) {
string s, t;
cin >> s >> t;
int x, y;
rep(i, (int)s.size()) {
if (s[i] == ':') {
x = i;
}
}
rep(i, (int)t.size()) {
if (t[i] == ':') {
y = i;
}
}
int a = stoi(s.substr(0, x)), b = stoi(s.substr(x + 1));
int c = stoi(t.substr(0, y)), d = stoi(t.substr(y + 1));
ans += calc(a, b, c, d);
}
cout << ans << endl;
}
Tatsu_mr