結果

問題 No.652 E869120 and TimeZone
ユーザー kichirb3
提出日時 2018-03-06 23:32:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,058 bytes
コンパイル時間 782 ms
コンパイル使用メモリ 73,088 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-11 12:24:16
合計ジャッジ時間 1,542 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.652 E869120 and TimeZone
// https://yukicoder.me/problems/no/652
//

#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int decode_time(string &S);


int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int a, b;
    string S;
    cin >> a >> b >> S;

    int japanese_time = a * 60 + b;
    int time_diff = decode_time(S);
    int ans = japanese_time + time_diff - 540;

    if (ans < 0)
        ans += 24 * 60;
    else if (ans >= 24 * 60)
        ans -= 24 * 60;

    cout << setw(2) << setfill('0') << ans / 60 << ":";
    cout << setw(2) << setfill('0') << ans % 60 << endl;
}

int decode_time(string &S) {
    int ans;
    auto pos = S.find(".");
    if (pos != string::npos) {
        int hh = stoi(S.substr(3, pos)) * 60;
        int mm = stoi(S.substr(S.size()-1, S.size())) * 6;
        if (S[3] == '-')
            hh -= mm;
        else
            hh += mm;
        ans = hh;
    } else {
        ans = stoi(S.substr(3, S.size())) * 60;
    }
    return ans;
}
0