結果
| 問題 |
No.70 睡眠の重要性!
|
| コンテスト | |
| ユーザー |
ku_material_ro
|
| 提出日時 | 2016-09-14 23:46:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,071 bytes |
| コンパイル時間 | 489 ms |
| コンパイル使用メモリ | 59,516 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 05:59:12 |
| 合計ジャッジ時間 | 951 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
ソースコード
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
int n;
int a,b;
int H, h, M, m;
int dh, dm;
int ans = 0;
string s1;
string s2;
cin >> n;
for (int i = 0; i < n; i++){
cin >> s1;
cin >> s2;
a = s1.find(":");
if (a == 1){
H = s1[0] - '0';
if (s1[3] == '\0'){
M = s1[2] - '0';
}
else{
M = (s1[2] - '0') * 10 + (s1[3] - '0');
}
}
else{
H = (s1[0] - '0') * 10 + (s1[1] - '0');
if (s1[4] == '\0'){
M = s1[3] - '0';
}
else{
M = (s1[3] - '0') * 10 + (s1[4] - '0');
}
}
b = s2.find(":");
if (b == 1){
h = s2[0] - '0';
if (s2[3] == '\0'){
m = s2[2] - '0';
}
else{
m = (s2[2] - '0') * 10 + (s2[3] - '0');
}
}
else{
h = (s2[0] - '0') * 10 + (s2[1] - '0');
if (s2[4] == '\0'){
m = s2[3] - '0';
}
else{
m = (s2[3] - '0') * 10 + (s2[4] - '0');
}
}
dh = h - H;
dm = m - M;
if (dm < 0){
dm += 60;
dh -= 1;
}
if (dh < 0){
dh += 24;
}
ans += dh * 60 + dm;
}
cout << ans << endl;
return 0;
}
ku_material_ro