結果

問題 No.9 モンスターのレベル上げ
ユーザー NotationNap
提出日時 2015-04-22 04:26:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 514 ms / 5,000 ms
コード長 695 bytes
コンパイル時間 1,371 ms
コンパイル使用メモリ 165,408 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-23 22:34:52
合計ジャッジ時間 6,395 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long Int;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);++(i))

int A[1500];
int B[1500];
int main() {
	int N;
	cin >> N;
	REP(i, N) cin >> A[i];
	REP(i, N) cin >> B[i];

	int ans = 999999999;
	REP(i, N) {
		priority_queue<pair<int, int>> pq;
		REP(j, N) {
			pq.push(make_pair(-A[j], 0));
		}
		for (int j = 0; j < N; j++) {
			pair<int,int> top = pq.top();
			pq.pop();
			top.first -= B[(i + j) % N] / 2;
			top.second--;
			pq.push(top);
		}

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