結果

問題 No.70 睡眠の重要性!
ユーザー ajiruajiruajiruajiru
提出日時 2020-02-05 00:38:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 751 bytes
コンパイル時間 1,453 ms
コンパイル使用メモリ 67,676 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 06:43:20
合計ジャッジ時間 1,353 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	string HM, hm;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		cin >> HM >> hm;
		int pos = HM.find(':');
		string H = HM.substr(0, pos),
			M = HM.substr(pos + 1);

		pos = hm.find(':');
		string h = hm.substr(0, pos),
			m = hm.substr(pos + 1);

		int h1 = stoi(H), m1 = stoi(M),
			h2 = stoi(h), m2 = stoi(m);
		if (h1 == h2) {
			if (m2 >= m1) ans += m2 - m1;
			else ans += 1440 - (m1 - m2);
		}
		else if (h2 > h1) {
			ans += 60 - m1;
			ans += (h2 - h1 - 1) * 60;
			ans += m2;
		}
		else if (h1 > h2) {
			ans += 60 - m1;
			ans += (24 - h1 - 1) * 60;
			ans += h2 * 60;
			ans += m2;
		}
	}
	cout << ans << endl;
	return 0;
}
0