結果
問題 | No.70 睡眠の重要性! |
ユーザー |
![]() |
提出日時 | 2019-05-23 17:03:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 469 bytes |
コンパイル時間 | 392 ms |
コンパイル使用メモリ | 56,252 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 09:46:51 |
合計ジャッジ時間 | 847 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d:%d %d:%d", &H, &M, &h, &m); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>using namespace std;int main() {int n, sumH=0, sumM=0;cin >> n;for (int i=0; i<n; i++) {int H, M, h, m;scanf("%d:%d %d:%d", &H, &M, &h, &m);if (H>h) {sumH+=24-(H+1)+h;sumM+=60-M+m;} else if (H<h) {sumH+=h-H-1;sumM+=60-M+m;} else {if (M<m) {sumM+=m-M;} else {sumH+=23;sumM+=60-M;}}}cout << sumH*60+sumM << endl;return 0;}