結果

問題 No.70 睡眠の重要性!
ユーザー ミドリムシミドリムシ
提出日時 2017-10-14 04:18:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 629 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 59,784 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 01:18:08
合計ジャッジ時間 990 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cmath>
using namespace std;

void time_to_num(string T, int* H, int* M){
	string string_H = "", string_M = "";
	int now = 0;
	for(int i = 0; i < T.size(); i++){
		if(T[i] == ':'){
			now++;
		}else if(now == 0){
			string_H.push_back(T[i]);
		}else if(now == 1){
			string_M.push_back(T[i]);
		}
	}
	*H = stoi(string_H);
	*M = stoi(string_M);
}
 
int main(){
	int N;
	cin >> N;
	int ans = 0;
	for(int i = 0; i < N; i++){
		string S, W;
		cin >> S >> W;
		int H, M, h, m;
		time_to_num(S, &H, &M);
		time_to_num(W, &h, &m);
		ans += (h * 60 + m + 1440 - H * 60 - M) % 1440;
	}
	cout << ans << endl;
}
0