結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー a9ua1i0na9ua1i0n
提出日時 2022-10-14 22:06:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,528 bytes
コンパイル時間 1,860 ms
コンパイル使用メモリ 144,048 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 21:48:31
合計ジャッジ時間 13,740 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 113 ms
4,380 KB
testcase_02 AC 114 ms
4,380 KB
testcase_03 AC 210 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 112 ms
4,380 KB
testcase_06 AC 111 ms
4,384 KB
testcase_07 AC 113 ms
4,376 KB
testcase_08 AC 121 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 117 ms
4,380 KB
testcase_11 AC 116 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 209 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 114 ms
4,380 KB
testcase_16 AC 114 ms
4,380 KB
testcase_17 AC 113 ms
4,380 KB
testcase_18 AC 114 ms
4,376 KB
testcase_19 AC 114 ms
4,380 KB
testcase_20 AC 113 ms
4,380 KB
testcase_21 AC 113 ms
4,384 KB
testcase_22 WA -
testcase_23 AC 113 ms
4,380 KB
testcase_24 AC 113 ms
4,376 KB
testcase_25 AC 113 ms
4,384 KB
testcase_26 AC 113 ms
4,380 KB
testcase_27 AC 116 ms
4,380 KB
testcase_28 AC 212 ms
4,380 KB
testcase_29 WA -
testcase_30 AC 113 ms
4,380 KB
testcase_31 AC 115 ms
4,376 KB
testcase_32 AC 113 ms
4,380 KB
testcase_33 AC 211 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 113 ms
4,380 KB
testcase_36 AC 114 ms
4,380 KB
testcase_37 AC 113 ms
4,376 KB
testcase_38 AC 114 ms
4,380 KB
testcase_39 AC 113 ms
4,380 KB
testcase_40 WA -
testcase_41 AC 120 ms
4,380 KB
testcase_42 AC 114 ms
4,376 KB
testcase_43 AC 113 ms
4,380 KB
testcase_44 AC 114 ms
4,376 KB
testcase_45 AC 114 ms
4,384 KB
testcase_46 WA -
testcase_47 AC 114 ms
4,380 KB
testcase_48 AC 211 ms
4,376 KB
testcase_49 WA -
testcase_50 AC 114 ms
4,380 KB
testcase_51 AC 114 ms
4,376 KB
testcase_52 AC 114 ms
4,376 KB
testcase_53 WA -
testcase_54 AC 113 ms
4,380 KB
testcase_55 WA -
testcase_56 AC 114 ms
4,376 KB
testcase_57 AC 113 ms
4,384 KB
testcase_58 AC 114 ms
4,384 KB
testcase_59 AC 114 ms
4,384 KB
testcase_60 AC 113 ms
4,380 KB
testcase_61 AC 114 ms
4,380 KB
testcase_62 AC 114 ms
4,380 KB
testcase_63 WA -
testcase_64 AC 114 ms
4,376 KB
testcase_65 WA -
testcase_66 AC 114 ms
4,380 KB
testcase_67 WA -
testcase_68 AC 114 ms
4,380 KB
testcase_69 AC 114 ms
4,380 KB
testcase_70 AC 114 ms
4,380 KB
testcase_71 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#if !__INCLUDE_LEVEL__
    #include __FILE__

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

    ll T, X, A, Y, B;
    cin >> T >> X >> A >> Y >> B;

    bool is_back = T < 0;
    if (T < 0) {
        T *= -1;
        swap(X, Y);
        swap(A, B);
    }
    // B *= -1;

    if ((!is_back) && X >= A) {
        cout << T << "\n";
        return 0;
    }

    ll TT = T % A;
    ll ans = T / A * X;
    cerr << ans << "\n";
    ll add_cost = is_back ? 1e14 : TT;
    REP(i, 1e7) {
        if (i == 0)
            continue;
        ll cost = X * i;
        if ((A * i - TT) % B == 0) {
            cost += Y * (A * i - TT) / B;
        } else {
            cost += Y * ((A * i - TT) / B) + ((A * i - TT) % B);
        }
        add_cost = min(add_cost, cost);
    }

    cout << ans + add_cost << "\n";

    return 0;
}

//====================temp====================
#else
    #include <bits/stdc++.h>
using namespace std;
    #define REP(i, n) for (int i = 0; i < (int)(n); i++)
    #define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
    #define REPITR(itr, ARRAY) \
        for (auto itr = (ARRAY).begin(); itr != (ARRAY).end(); ++itr)
    #define RREPITR(itr, ARRAY) \
        for (auto itr = (ARRAY).rbegin(); itr != (ARRAY).rend(); ++itr)
    #define ALL(n) (n).begin(), (n).end()
using ll = long long;
using ull = unsigned long long;
//#define int long long
template<typename T> struct edge {
    int to;
    T cost;
    edge() {}
    edge(int to, T cost): to(to), cost(cost) {}
};
#endif
0