結果

問題 No.70 睡眠の重要性!
ユーザー hanorverhanorver
提出日時 2015-09-02 22:43:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 892 bytes
コンパイル時間 1,064 ms
コンパイル使用メモリ 60,280 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 02:20:14
合計ジャッジ時間 2,001 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0