結果

問題 No.70 睡眠の重要性!
ユーザー mikoricemikorice
提出日時 2018-03-04 11:38:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,256 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 82,520 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 09:23:21
合計ジャッジ時間 1,301 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

vector<string> split(string s, string delim) {
    vector<string> res;
    int pos = 0;
    while(true) {
        int found = s.find(delim, pos);
        if(found >= 0) {
            res.push_back(s.substr(pos, found - pos));
        }
        else {
            res.push_back(s.substr(pos));
            break;
        }
        pos = found + delim.size();
    }
    return res;
	}

int main() {
	int n,ans;
	cin >> n;
	string a,b;
	vector<string> a0,b0;
	string thresh = ":";
	ans = 0;
	int a1,a2,b1,b2;
	int hr,mn;
	REP(i,n){
		cin >> a >> b;
		a0 = split(a, thresh);
		b0 = split(b, thresh);
		a1 = stoi(a0[0]);
		a2 = stoi(a0[1]);
		b1 = stoi(b0[0]);
		b2 = stoi(b0[1]);
		hr = b1-a1;

		mn = b2-a2;
		if(mn < 0){
			mn += 60;
			hr -= 1;
		}
		if(hr < 0) hr += 24;
		ans += mn + hr*60;
	}

	cout << ans << endl;
	return 0;
}
0