結果

問題 No.70 睡眠の重要性!
ユーザー IL_mstaIL_msta
提出日時 2015-05-31 11:45:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,180 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 66,836 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 17:57:32
合計ジャッジ時間 1,022 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <string>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;//
	//cout << setprecision(7);//
	
	int N;
	cin>>N;
	int aH[30],aM[30];
	int bH[30],bM[30];
	string Astr,Bstr;
	rep(k,N){
		cin>>Astr>>Bstr;
		int i=0;
		aH[k] = 0;
		aM[k] = 0;
		bH[k] = 0;
		bM[k] = 0;
		for(i=0;Astr[i] != ':';++i){
			aH[k] = aH[k]*10 + Astr[i] - '0';
		}
		++i;
		for(;i<Astr.size();++i){
			aM[k] = aM[k]*10 + Astr[i] - '0';
		}
		for(i=0;Bstr[i] != ':';++i){
			bH[k] = bH[k]*10 + Bstr[i] - '0';
		}
		++i;
		for(;i<Bstr.size();++i){
			bM[k] = bM[k]*10 + Bstr[i] - '0';
		}
	}
	/*
	for(int i=0;i<N;++i){
		cout << aH[i] << ":" << aM[i] << " " << bH[i] << ":" << bM[i] << endl;
	}*/
	////////////////
	int ans  = 0;
	int neru = 0;
	int oki  = 0;
	rep(i,N){
		neru = aH[i]*60+aM[i];
		oki  = bH[i]*60+bM[i];
		if(neru > oki){
			oki += 24*60;
		}
		ans += oki-neru;
	}
	P(ans);
	return 0;
}
0