結果

問題 No.9 モンスターのレベル上げ
コンテスト
ユーザー tsukio
提出日時 2016-03-13 02:10:40
言語 C++11(old_compat)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -include bits/stdc++.h -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 417 ms / 5,000 ms
コード長 909 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,050 ms
コンパイル使用メモリ 173,088 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-08 16:05:53
合計ジャッジ時間 4,889 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;
typedef pair<int, int> pii;

int main() {	
	int n;
	cin >> n;

	int level_allys[1500];
	int level_enemys[1500];
	
	for (int i = 0; i < n; i++) {
		cin >> level_allys[i];
	}

	for (int i = 0; i < n; i++) {
		cin >> level_enemys[i];
	}

	priority_queue<pii, vector<pii>, greater<pii>> q;
	int ans = numeric_limits<int>::max();
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			q.push(make_pair(level_allys[j], 0));
		}
		for (int j = 0; j < n; j++) {
			auto pair = q.top();
			q.pop();
			int add = level_enemys[(i + j) % n] / 2;
			q.push(make_pair(pair.first + add, pair.second + 1));
		}

		int max_count = 0;
		while (q.size() > 0) {
			auto pair = q.top();
			q.pop();
			max_count = max(max_count, pair.second);
		}

		ans = min(ans, max_count);
	}

	cout << ans << endl;

	return 0;
}
0