結果

問題 No.9 モンスターのレベル上げ
ユーザー 37kt_37kt_
提出日時 2015-10-28 11:51:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 263 ms / 5,000 ms
コード長 652 bytes
コンパイル時間 1,307 ms
コンパイル使用メモリ 151,152 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-06 04:26:01
合計ジャッジ時間 4,611 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 263 ms
4,388 KB
testcase_03 AC 212 ms
4,380 KB
testcase_04 AC 110 ms
4,384 KB
testcase_05 AC 72 ms
4,380 KB
testcase_06 AC 25 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 34 ms
4,380 KB
testcase_09 AC 261 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 196 ms
4,380 KB
testcase_12 AC 171 ms
4,380 KB
testcase_13 AC 159 ms
4,380 KB
testcase_14 AC 262 ms
4,380 KB
testcase_15 AC 236 ms
4,384 KB
testcase_16 AC 5 ms
4,384 KB
testcase_17 AC 152 ms
4,384 KB
testcase_18 AC 127 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef pair<int, int> P;

int n;
int a[1500], b[3000];

int calc(int a[], int b[])
{
	priority_queue<P, vector<P>, greater<P>> pq;
	for (int i = 0; i < n; i++){
		pq.push(P(a[i], 0));
	}

	int res = 0;
	for (int i = 0; i < n; i++){
		int lv, ct;
		tie(lv, ct) = pq.top(); pq.pop();
		pq.push(P(lv + b[i] / 2, ct + 1));
		res = max(res, ct + 1);
	}

	return res;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i], b[i + n] = b[i];
	
	int res = 1 << 28;
	for (int i = 0; i < n; i++){
		res = min(res, calc(a, b + i));
	}

	cout << res << endl;
}
0