結果

問題 No.70 睡眠の重要性!
ユーザー hayakawa4739hayakawa4739
提出日時 2018-06-25 15:48:40
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 980 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 29,184 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 13:51:14
合計ジャッジ時間 873 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

int main(void){

	int n;

	scanf("%d",&n);

	int **time;
	int count = 0;
	int check = 0;

	time = malloc(sizeof(int *)*n);

	for(int i = 0;i < n;i++){
		time[i] = malloc(sizeof(int) * 4);
	}

	for(int i = 0;i < n;i++){
		scanf("%d:%d",&time[i][0],&time[i][1]);
		scanf("%d:%d",&time[i][2],&time[i][3]);
	}

	for(int i = 0;i < n;i++){

		check = 0;

		if(time[i][1] > time[i][3]){
			check = 1;
			count += time[i][3]+60-time[i][1];
		}else{
			count += time[i][3]-time[i][1];
		}

		if(check == 1){
			if(time[i][0] >= time[i][2]){
				count += (time[i][2]+24-1-time[i][0])*60;
			}else{
				count += (time[i][2]-1-time[i][0])*60;
			}
		}else{
			if(time[i][0] > time[i][2]){
				count += (time[i][2]+24-time[i][0])*60;
			}else{
				count += (time[i][2]-time[i][0])*60;
			}
		}

	}

	printf("%d\n",count);

	for(int i = 0;i < n;i++){
		free(time[i]);
	}
	free(time);
	return 0;
}
0