結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-10-14 21:47:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 571 bytes
コンパイル時間 2,343 ms
コンパイル使用メモリ 192,352 KB
最終ジャッジ日時 2025-02-08 03:38:16
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
    ll t, x, a, y, b;
    cin >> t >> x >> a >> y >> b;
    ll ans = 0;
    if (t < 0) {
        ll s = (-t + b - 1) / b;
        ans = s * y;
        t = s * b + t;
    }
    ans += (t / a) * x;
    t %= a;
    for (ll i = 1; i < t; i ++) {
        ll s = i * x;
        ll t2 = i * a - t;
        ll pk = ((t2 + b - 1) / b);
        s += pk * y;
        t2 = pk * b - t2;
        if (s >= t) {
            break;
        }
        ans = min(ans, s + t2);
    }
    cout << ans << endl;
}
0