結果

問題 No.9 モンスターのレベル上げ
ユーザー 古寺いろは古寺いろは
提出日時 2015-04-16 01:08:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 430 ms / 5,000 ms
コード長 686 bytes
コンパイル時間 1,266 ms
コンパイル使用メモリ 150,920 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 03:43:56
合計ジャッジ時間 5,888 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 421 ms
4,380 KB
testcase_03 AC 346 ms
4,380 KB
testcase_04 AC 182 ms
4,376 KB
testcase_05 AC 113 ms
4,380 KB
testcase_06 AC 40 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 54 ms
4,380 KB
testcase_09 AC 423 ms
4,376 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 360 ms
4,380 KB
testcase_12 AC 310 ms
4,384 KB
testcase_13 AC 215 ms
4,380 KB
testcase_14 AC 430 ms
4,376 KB
testcase_15 AC 393 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 250 ms
4,376 KB
testcase_18 AC 210 ms
4,380 KB
testcase_19 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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