結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー Manuel1024
提出日時 2022-12-11 06:56:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 514 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 70,332 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 05:29:47
合計ジャッジ時間 9,800 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 72
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(){
    int t; cin >> t;
    int x, a; cin >> x >> a;
    int y, b; cin >> y >> b;

    ll ans = 1LL << 60;
    for(int i = 0; i < 10000010; i++){
        ll res = 0;
        ll t1 = t;
        res += 1LL*y*i;
        t1 += 1LL*b*i;
        if(t1 < 0) continue;
        ll c1 = t1/a;
        res += x*c1;
        res += t1-a*c1;
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}
0