結果

問題 No.9 モンスターのレベル上げ
ユーザー ldsyb
提出日時 2017-06-17 00:02:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 459 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 910 ms
コンパイル使用メモリ 76,336 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 00:10:08
合計ジャッジ時間 5,532 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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