結果

問題 No.2099 [Cherry Alpha B] Time Machine
ユーザー NAMIDAIRO
提出日時 2022-10-15 13:47:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 809 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 99,240 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 19:45:38
合計ジャッジ時間 3,504 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 nx = t / a;
		t -= a * nx;
		base += x * nx;
	}
	
	ll ans = 1e18;

	for (ll nx = 0; nx < y; nx++) {//xの回数
		ll now = a * nx;
		ll res = x * nx;
		if (now <= t) res += t - now;
		else {
			ll ny = (now - t - 1) / b + 1;
			now -= b * ny;
			res += y * ny + t - now;
		}
		ans = min(ans, res);
	}
	cout << ans + base << endl;
	return 0;
}
0