結果
| 問題 |
No.70 睡眠の重要性!
|
| コンテスト | |
| ユーザー |
aaa
|
| 提出日時 | 2018-10-05 19:44:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,935 bytes |
| コンパイル時間 | 1,031 ms |
| コンパイル使用メモリ | 103,608 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 12:44:46 |
| 合計ジャッジ時間 | 1,777 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
ソースコード
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
using namespace std;
int main() {
int i, j, k;
int n;
vector<string>s1, s2;
vector<int>h1, h2, m1, m2;
cin >> n;
for (i = 0; i < n; i++) {
string sa, sb;
cin >> sa;
s1.push_back(sa);
string sh, sm;
bool flag = false;
for (j = 0; j < sa.length(); j++) {
if (flag==false && sa[j] != ':') {
sh += sa[j];
}
else if (flag == true && sa[j] != ':') {
sm += sa[j];
//flag = true;
}
if (sa[j] == ':') {
flag = true;
}
}
h1.push_back(stoi(sh));
m1.push_back(stoi(sm));
cin >> sb;
s2.push_back(sb);
sh = ""; sm = "";
flag = false;
for (j = 0; j < sb.length(); j++) {
if (flag == false && sb[j] != ':') {
sh += sb[j];
}
else if (flag == true && sb[j] != ':') {
sm += sb[j];
//flag = true;
}
if (sb[j] == ':') {
flag = true;
}
}
h2.push_back(stoi(sh));
m2.push_back(stoi(sm));
}
int h = 0, m = 0;
for (i = 0; i < n; i++) {
if (h1[i] < h2[i]) {
h += (h2[i] - h1[i]);
if (m1[i] <= m2[i]) {
}
else if (m1[i] > m2[i]) {
h--;
}
}
else if (h1[i] > h2[i]) {
h += (24 - h1[i]);
h += h2[i];
//h += (h2[i] - h1[i]);
if (m1[i] <= m2[i]) {
}
else if (m1[i] > m2[i]) {
h--;
}
}
else if (h1[i] == h2[i]) {
if (m1[i] < m2[i]) {
}
else if (m1[i] > m2[i]) {
h += 23;
}
}
if (m1[i] <= m2[i]) {
m += (m2[i] - m1[i]);
}
else {
m += (60 - m1[i]) + m2[i];
}
//cout << "i->" << i << " " << "h->" << h << " " << "m->" << m << endl;
}
cout << (h * 60) + m << endl;
getchar();
getchar();
return 0;
}
aaa