結果

問題 No.1862 Copy and Paste
ユーザー vjudge1vjudge1
提出日時 2024-05-01 23:27:54
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 874 bytes
コンパイル時間 4,372 ms
コンパイル使用メモリ 278,800 KB
実行使用メモリ 16,968 KB
最終ジャッジ日時 2024-11-22 07:27:15
合計ジャッジ時間 68,851 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6 TLE * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	// yeeettt
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// iad
	int a, b, n;
	cin >> a >> b >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}

	// temp answer
	int answer = a + (n - 1) * b;
	// iterate
	for (int use1 = 2; (1 << (use1 - 1)) <= n; use1++) {
		// dedlaratiom
		priority_queue<int, vector<int>, greater<int>> pq;
		int duck = 1;
		int use2 = use1;
		for (int i = 1; i <= use1; i++) duck *= 2;
		for (int i = 1; i <= use1; i++) pq.push(2);

		// reiterate
		while (duck < n) {
			int now = pq.top();
			pq.pop();
			duck *= now + 1;
			duck /= now;
			use2 += 1;
			pq.push(now + 1);
		}

		// find the smallest valid one
		answer = min(answer, a * use1 + b * use2);
	}

	// final nail to the cofin
	cout << answer << endl;

	return 0;
}
0