結果
| 問題 |
No.70 睡眠の重要性!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-12 12:11:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,023 bytes |
| コンパイル時間 | 576 ms |
| コンパイル使用メモリ | 58,460 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 17:03:52 |
| 合計ジャッジ時間 | 1,070 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:49:13: warning: ‘total’ may be used uninitialized in this function [-Wmaybe-uninitialized]
49 | cout << total << endl;
| ^~~~~
main.cpp:40:12: warning: ‘nd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
40 | nd += stoi(tm);
| ~~~^~~~~~~~~~~
main.cpp:28:13: warning: ‘stt’ may be used uninitialized in this function [-Wmaybe-uninitialized]
28 | stt += stoi(tm);
| ~~~~^~~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;
int total;
cin >> n;
for (int i = 0; i < n; i++) {
string start;
string end;
cin >> start >> std::ws >> end;
string tm;
int stt;
for (int j = 0; j < start.length(); j++) {
if (start[j] == ':') {
stt = 60 * stoi(tm);
tm = "";
} else {
tm += start[j];
}
}
stt += stoi(tm);
tm = "";
int nd;
for (int k = 0; k < end.length(); k++) {
if (end[k] == ':') {
nd = 60 * stoi(tm);
tm = "";
} else {
tm += end[k];
}
}
nd += stoi(tm);
if (nd > stt) {
total += nd - stt;
} else {
total += (60 * 24 - stt) + nd;
}
}
cout << total << endl;
return 0;
}