結果

問題 No.2099 [Cherry Alpha B] Time Machine
コンテスト
ユーザー NAMIDAIRO
提出日時 2022-10-15 13:47:20
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 809 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 562 ms
コンパイル使用メモリ 114,324 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-13 13:55:54
合計ジャッジ時間 2,416 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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