結果

問題 No.9 モンスターのレベル上げ
ユーザー ldsybldsyb
提出日時 2017-06-17 00:02:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 442 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 75,144 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 05:28:11
合計ジャッジ時間 5,380 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 442 ms
4,376 KB
testcase_03 AC 353 ms
4,380 KB
testcase_04 AC 186 ms
4,380 KB
testcase_05 AC 122 ms
4,376 KB
testcase_06 AC 41 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 55 ms
4,380 KB
testcase_09 AC 433 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 365 ms
4,376 KB
testcase_12 AC 296 ms
4,380 KB
testcase_13 AC 205 ms
4,376 KB
testcase_14 AC 433 ms
4,376 KB
testcase_15 AC 393 ms
4,376 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 251 ms
4,380 KB
testcase_18 AC 214 ms
4,376 KB
testcase_19 AC 6 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n], b[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	int ans = 1 << 30;
	for(int i = 0; i < n; i++){
		priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;	//	first -> レベル, second -> 何回戦ったか
		for(int j = 0; j < n; j++) pq.push({a[j], 0});
		for(int j = 0; j < n; j++){
			pair<int, int> p = pq.top();
			pq.pop();
			pq.push({p.first + b[(i + j) % n] / 2, p.second + 1});
		}
		int tmp = 0;
		while(!pq.empty()){
			tmp = max(tmp, pq.top().second);
			pq.pop();
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}
0