結果
| 問題 |
No.70 睡眠の重要性!
|
| コンテスト | |
| ユーザー |
dgd1724
|
| 提出日時 | 2016-09-20 07:03:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,567 bytes |
| コンパイル時間 | 832 ms |
| コンパイル使用メモリ | 95,920 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 10:05:44 |
| 合計ジャッジ時間 | 1,250 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
ソースコード
#define _USE_MATH_DEFINES //M_PI
#include <iostream> //std::cout, std::cin
#include <string> //std::string
#include <vector> //std::vector
#include <valarray> //std::valarray 数値のみの一次配列
#include <algorithm> //std::sort
#include <time.h> //localtime_s
#include <cstdlib> //abs
#include <cmath> //abs, std::pow, sqrt, sin, cos,
#include <fstream> //std::ifstream
#include <iomanip> //std::setprecision
#include <random> //std::random(C++11)
#include <numeric> //std::accumulate
int main(void) {
//test用
//std::ifstream in("test.txt");
//std::cin.rdbuf(in.rdbuf());
int N;
std::string str1, str2;
std::cin >> N;
int ans = 0;
for (int i = 0; i < N; i++) {
std::cin >> str1 >> str2;
std::string temp;
int s_h, s_m, w_h, w_m;
int j = 0;
while (str1[j] != ':') {
temp.push_back(str1[j]);
j++;
}
s_h = std::stoi(temp);
j++;
temp.clear();
while (j < str1.length()) {
temp.push_back(str1[j]);
j++;
}
s_m = std::stoi(temp);
j = 0;
temp.clear();
while (str2[j] != ':') {
temp.push_back(str2[j]);
j++;
}
w_h = std::stoi(temp);
j++;
temp.clear();
while (j < str2.length()) {
temp.push_back(str2[j]);
j++;
}
w_m = std::stoi(temp);
if (s_h > w_h) {
ans += (24 - s_h - 1) * 60 + (60 - s_m) + w_h * 60 + w_m;
}
else if (s_h < w_h) {
ans += (w_h - s_h - 1) * 60 + (60 - s_m) + w_m;
}
else {
if (w_m >= s_m) {
ans += w_m - s_m;
}
else {
ans += 23 * 60 + (60 - s_m) + w_m;
}
}
}
std::cout << ans << std::endl;
}
dgd1724