結果

問題 No.9 モンスターのレベル上げ
ユーザー rkrmrrkrmr
提出日時 2017-06-17 00:02:52
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 509 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 544 ms
使用メモリ 3,568 KB
最終ジャッジ日時 2023-01-21 16:43:32
合計ジャッジ時間 6,123 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
3,472 KB
testcase_01 AC 2 ms
3,500 KB
testcase_02 AC 509 ms
3,484 KB
testcase_03 AC 405 ms
3,512 KB
testcase_04 AC 212 ms
3,492 KB
testcase_05 AC 139 ms
3,392 KB
testcase_06 AC 48 ms
3,452 KB
testcase_07 AC 2 ms
3,532 KB
testcase_08 AC 64 ms
3,552 KB
testcase_09 AC 495 ms
3,412 KB
testcase_10 AC 1 ms
3,528 KB
testcase_11 AC 430 ms
3,568 KB
testcase_12 AC 320 ms
3,468 KB
testcase_13 AC 218 ms
3,420 KB
testcase_14 AC 496 ms
3,416 KB
testcase_15 AC 450 ms
3,488 KB
testcase_16 AC 8 ms
3,528 KB
testcase_17 AC 289 ms
3,508 KB
testcase_18 AC 243 ms
3,412 KB
testcase_19 AC 5 ms
3,488 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