結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー shell_mugshell_mug
提出日時 2022-10-14 22:16:27
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 1,812 bytes
コンパイル時間 5,819 ms
コンパイル使用メモリ 123,640 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-08 22:07:33
合計ジャッジ時間 12,146 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 124 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 41 ms
4,376 KB
testcase_09 AC 39 ms
4,376 KB
testcase_10 AC 44 ms
4,380 KB
testcase_11 AC 46 ms
4,380 KB
testcase_12 AC 22 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 125 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 34 ms
4,380 KB
testcase_19 AC 34 ms
4,376 KB
testcase_20 AC 31 ms
4,380 KB
testcase_21 AC 28 ms
4,376 KB
testcase_22 AC 44 ms
4,380 KB
testcase_23 AC 21 ms
4,384 KB
testcase_24 AC 45 ms
4,376 KB
testcase_25 AC 25 ms
4,376 KB
testcase_26 AC 34 ms
4,376 KB
testcase_27 AC 19 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 124 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 125 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 32 ms
4,380 KB
testcase_39 AC 16 ms
4,380 KB
testcase_40 AC 30 ms
4,376 KB
testcase_41 AC 10 ms
4,384 KB
testcase_42 AC 37 ms
4,384 KB
testcase_43 AC 35 ms
4,380 KB
testcase_44 AC 36 ms
4,388 KB
testcase_45 AC 32 ms
4,380 KB
testcase_46 AC 29 ms
4,380 KB
testcase_47 AC 17 ms
4,376 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,380 KB
testcase_50 AC 124 ms
4,384 KB
testcase_51 AC 1 ms
4,376 KB
testcase_52 AC 2 ms
4,380 KB
testcase_53 AC 1 ms
4,380 KB
testcase_54 AC 1 ms
4,380 KB
testcase_55 AC 34 ms
4,376 KB
testcase_56 AC 124 ms
4,380 KB
testcase_57 AC 124 ms
4,380 KB
testcase_58 AC 124 ms
4,380 KB
testcase_59 AC 123 ms
4,376 KB
testcase_60 AC 124 ms
4,380 KB
testcase_61 AC 124 ms
4,376 KB
testcase_62 AC 124 ms
4,380 KB
testcase_63 AC 124 ms
4,380 KB
testcase_64 AC 124 ms
4,384 KB
testcase_65 AC 123 ms
4,380 KB
testcase_66 AC 124 ms
4,380 KB
testcase_67 AC 124 ms
4,380 KB
testcase_68 AC 124 ms
4,380 KB
testcase_69 AC 124 ms
4,376 KB
testcase_70 AC 124 ms
4,384 KB
testcase_71 AC 124 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
#include <atcoder/all>
using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t, x, a, y, b;
    cin >> t >> x >> a >> y >> b;
    
    ll ans = 1e18, cost_b = (max(a * b - t, 0LL) + b - 1) / b;
    while (cost_b >= 0) {
        ll day_b = -cost_b * b;
        if (day_b > t) break;
        chmin(ans, (t - day_b) / a * x + cost_b * y + (t - day_b) % a);
        eprintf("cost_b=%lld day_b=%lld\n", cost_b, day_b);
        --cost_b;
    }
    cout << ans << endl;
    return 0;
}
0