結果
| 問題 |
No.652 E869120 and TimeZone
|
| コンテスト | |
| ユーザー |
CELICA
|
| 提出日時 | 2020-09-01 08:04:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 760 bytes |
| コンパイル時間 | 1,451 ms |
| コンパイル使用メモリ | 170,332 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-11 12:33:34 |
| 合計ジャッジ時間 | 2,328 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ul = unsigned long;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int a, b;
string s;
cin >> a >> b >> s;
int t1 = a * 60 + b;
auto pos = s.find('.');
int h, m;
if (pos != string::npos)
{
h = stoi(s.substr(4, pos - 3));
m = stoi(s.substr(pos + 1)) * 6;
}
else
{
h = stoi(s.substr(4));
m = 0;
}
int t2;
string op = s.substr(3, 1);
if (op == "+")
t2 = 540 - (h * 60 + m);
else
t2 = (9 + h) * 60 + m;
int t = t1 - t2;
if (t < 0)
t += 24 * 60;
int hh = (t / 60 + m / 60) % 24,
mm = t % 60;
string res;
res = (hh < 10 ? "0" : "") + to_string(hh)
+ ":"
+ (mm < 10 ? "0" : "") + to_string(mm);
cout << res << "\n";
return 0;
}
CELICA