結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー a9ua1i0na9ua1i0n
提出日時 2022-10-14 22:44:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,197 bytes
コンパイル時間 3,972 ms
コンパイル使用メモリ 144,364 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 23:03:12
合計ジャッジ時間 17,915 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
4,376 KB
testcase_01 AC 121 ms
4,376 KB
testcase_02 AC 213 ms
4,380 KB
testcase_03 AC 211 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 212 ms
4,380 KB
testcase_07 AC 120 ms
4,380 KB
testcase_08 AC 130 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 127 ms
4,380 KB
testcase_11 AC 122 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 211 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 212 ms
4,376 KB
testcase_17 AC 122 ms
4,384 KB
testcase_18 AC 208 ms
4,380 KB
testcase_19 AC 205 ms
4,380 KB
testcase_20 AC 195 ms
4,380 KB
testcase_21 AC 210 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 120 ms
4,376 KB
testcase_24 AC 201 ms
4,380 KB
testcase_25 AC 206 ms
4,376 KB
testcase_26 AC 211 ms
4,376 KB
testcase_27 AC 123 ms
4,384 KB
testcase_28 AC 212 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 212 ms
4,384 KB
testcase_32 AC 121 ms
4,380 KB
testcase_33 AC 211 ms
4,380 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 212 ms
4,380 KB
testcase_37 AC 120 ms
4,380 KB
testcase_38 AC 209 ms
4,380 KB
testcase_39 AC 212 ms
4,376 KB
testcase_40 WA -
testcase_41 AC 123 ms
4,380 KB
testcase_42 AC 207 ms
4,380 KB
testcase_43 AC 120 ms
4,380 KB
testcase_44 AC 210 ms
4,380 KB
testcase_45 AC 211 ms
4,380 KB
testcase_46 WA -
testcase_47 AC 211 ms
4,380 KB
testcase_48 AC 212 ms
4,376 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 213 ms
4,380 KB
testcase_52 AC 121 ms
4,380 KB
testcase_53 WA -
testcase_54 AC 212 ms
4,380 KB
testcase_55 WA -
testcase_56 AC 121 ms
4,380 KB
testcase_57 AC 213 ms
4,376 KB
testcase_58 AC 212 ms
4,380 KB
testcase_59 AC 121 ms
4,384 KB
testcase_60 AC 212 ms
4,384 KB
testcase_61 AC 120 ms
4,380 KB
testcase_62 AC 212 ms
4,376 KB
testcase_63 WA -
testcase_64 AC 212 ms
4,376 KB
testcase_65 WA -
testcase_66 AC 212 ms
4,380 KB
testcase_67 WA -
testcase_68 AC 212 ms
4,380 KB
testcase_69 AC 121 ms
4,380 KB
testcase_70 AC 212 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;

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

        ll TT = T % A;
        ll ans = T / A * X;
        cerr << ans << "\n";
        ll add_cost = 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 + 1) + ((A * i - TT) % B);
            }
            add_cost = min(add_cost, cost);
        }

        cout << ans + add_cost << "\n";
    } else {
        if (T % B == 0) {
            cout << T / B * Y << "\n";
            return 0;
        }
        T *= -1;
        ll TT = (T / B + 1) * B - T;
        ll ans = (T / B + 1) * Y;
        cerr << (T / B + 1) * B << "\n";
        ll add_cost = TT;
        REP(i, 1e7) {
            // if (i == 0)
            //     continue;
            if (TT + B * i < A)
                continue;

            ll cost = Y * i;

            if ((B * i + TT) % A == 0) {
                cost += X * (B * i + TT) / A;
            } else {
                cost += X * (B * i + TT) / A + ((B * i + TT) % A);
            }
            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