結果
| 問題 |
No.2099 [Cherry Alpha B] Time Machine
|
| コンテスト | |
| ユーザー |
NAMIDAIRO
|
| 提出日時 | 2022-10-15 14:03:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 227 ms / 2,000 ms |
| コード長 | 753 bytes |
| コンパイル時間 | 1,165 ms |
| コンパイル使用メモリ | 100,956 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 19:46:40 |
| 合計ジャッジ時間 | 18,985 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 72 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <random>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T>
using vi = vector<T>;
template<class T>
using vii = vector<vi<T>>;
template<class T>
using viii = vector<vii<T>>;
int main()
{
ll t, x, a, y, b;
cin >> t >> x >> a >> y >> b;
ll base = 0;
if (t < 0) {
ll ny = (-t - 1) / b + 1;
t += b * ny;
base += y * ny;
}
ll ans = 1e18;
for (ll ny = 0; ny < 2e7; ny++) {//yの回数
ll now = - b * ny;
ll nx = (t - now) / a;
ll res = y * ny + x * nx + (t - now - a * nx);
ans = min(ans, res);
}
cout << ans + base << endl;
return 0;
}
NAMIDAIRO