結果

問題 No.70 睡眠の重要性!
ユーザー Y_SY_S
提出日時 2020-08-05 06:38:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 953 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 14:08:14
合計ジャッジ時間 1,311 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <sstream>	//stringstream,getline

using namespace std;

inline vector<string> Split_String(const string& str, const char key) {

	vector<std::string> result;
	stringstream SS(str);
	string temp;

	while (getline(SS, temp, key)) {
		result.push_back(temp);
	}

	return(result);
}

int main() {

	int N;
	cin >> N;

	string temp;
	vector<string> A, B;

	int h = 0, m = 0;

	for (int i = 0; i < N; i++) {
		cin >> temp;
		A = Split_String(temp, ':');
		cin >> temp;
		B = Split_String(temp, ':');

		h += (stoi(B[0]) + 24 - stoi(A[0])) % 24;
		if (stoi(B[1]) < stoi(A[1])) {
			h--;
			if (h < 0) {
				h = 23;
			}
		}
		m += (stoi(B[1]) + 60 - stoi(A[1])) % 60;
	}

	cout << h * 60 + m << endl;

	return 0;

}
0