結果
問題 | No.70 睡眠の重要性! |
ユーザー |
![]() |
提出日時 | 2015-09-02 22:43:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 892 bytes |
コンパイル時間 | 480 ms |
コンパイル使用メモリ | 60,440 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 21:42:11 |
合計ジャッジ時間 | 1,156 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 |
ソースコード
#include<iostream> #include<algorithm> #include<string> int main() { int days; std::cin >> days; int sleep_time = 0; for (int i = 0; i < days; i++) { std::string sleep, wakeup; std::cin >> sleep >> wakeup; int it = sleep.find(':', 0); std::string sleep_hour = sleep.substr(0, it); sleep.erase(0, it + 1); it = wakeup.find(':', 0); std::string wakeup_hour = wakeup.substr(0, it); wakeup.erase(0, it + 1); int sleeph = std::stoi(sleep_hour); int sleepm = std::stoi(sleep); int wakeuph = std::stoi(wakeup_hour); int wakeupm = std::stoi(wakeup); if (wakeupm < sleepm) { sleep_time += (wakeupm + 60 - sleepm); wakeuph--; } else { sleep_time += wakeupm - sleepm; } if(wakeuph < sleeph){ sleep_time += (wakeuph + 24 - sleeph) * 60; } else { sleep_time += (wakeuph - sleeph) * 60; } } std::cout << sleep_time << std::endl; return 0; }