結果
問題 | No.2099 [Cherry Alpha B] Time Machine |
ユーザー |
![]() |
提出日時 | 2022-10-14 22:16:27 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 119 ms / 2,000 ms |
コード長 | 1,812 bytes |
コンパイル時間 | 4,047 ms |
コンパイル使用メモリ | 161,944 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 15:10:05 |
合計ジャッジ時間 | 7,702 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 72 |
ソースコード
#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; }