結果

問題 No.9 モンスターのレベル上げ
ユーザー 古寺いろは
提出日時 2015-04-16 01:08:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 434 ms / 5,000 ms
コード長 686 bytes
コンパイル時間 1,670 ms
コンパイル使用メモリ 166,224 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 22:34:10
合計ジャッジ時間 5,846 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int main() {
	int N;
	cin >> N;
	vector<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 = N;
	for (int i = 0; i < N; i++)
	{
		priority_queue<pair<int, int>> pq;
		for (int j = 0; j < N; j++)
		{
			pq.push(make_pair(-A[j], 0));
		}

		for (int j = 0; j < N; j++)
		{
			int up = B[(i + j) % N] / 2;
			auto now = pq.top(); pq.pop();
			pq.push(make_pair(now.first - up, now.second - 1));
		}

		int temp = 0;
		while (!pq.empty()){
			auto now = pq.top(); pq.pop();
			temp = max(temp, -now.second);
		}
		ans = min(temp, ans);
	}
	cout << ans << endl;
}



0