結果

問題 No.70 睡眠の重要性!
ユーザー daradara_sanmadaradara_sanma
提出日時 2017-07-02 13:59:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 56,412 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 11:55:55
合計ジャッジ時間 979 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d:%d %d:%d", &h, &m, &ht, &mt);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int n, h, m, ht, mt;
	scanf("%d", &n);

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		scanf("%d:%d %d:%d", &h, &m, &ht, &mt);
		int a = h * 60 + m;
		int b = ht * 60 + mt;
		if (b > a)
		{
			ans += (b - a);
		}
		else
		{
			ans += (b + 1440 - a);
		}
	}
	cout << ans << endl;

	return 0;
}
0