結果

問題 No.9 モンスターのレベル上げ
ユーザー mbanmban
提出日時 2017-01-15 03:20:56
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 274 ms / 5,000 ms
コード長 649 bytes
コンパイル時間 596 ms
使用メモリ 3,544 KB
最終ジャッジ日時 2023-01-21 16:15:18
合計ジャッジ時間 4,144 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,500 KB
testcase_01 AC 1 ms
3,472 KB
testcase_02 AC 274 ms
3,484 KB
testcase_03 AC 218 ms
3,408 KB
testcase_04 AC 116 ms
3,448 KB
testcase_05 AC 76 ms
3,392 KB
testcase_06 AC 27 ms
3,456 KB
testcase_07 AC 2 ms
3,428 KB
testcase_08 AC 35 ms
3,452 KB
testcase_09 AC 269 ms
3,472 KB
testcase_10 AC 1 ms
3,380 KB
testcase_11 AC 212 ms
3,444 KB
testcase_12 AC 176 ms
3,468 KB
testcase_13 AC 145 ms
3,544 KB
testcase_14 AC 271 ms
3,520 KB
testcase_15 AC 244 ms
3,464 KB
testcase_16 AC 5 ms
3,380 KB
testcase_17 AC 157 ms
3,408 KB
testcase_18 AC 132 ms
3,504 KB
testcase_19 AC 4 ms
3,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue>


using namespace std;

#define p pair<int,int>


int main() {
	int n;
	int i, j;
	int ans;
	cin >> n;
	vector<int>a(n);
	vector<int>b(n);
	b = vector<int>(n);
	for (int i = 0; i<n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i<n; i++) {
		cin >> b[i];
	}
	ans = n;
	for (i = 0; i<n; i++) {
		int t = 0;
		priority_queue<p, vector<p>, greater<p>> pq;
		for (j = 0; j<n; j++) {
			pq.push(p(a[j], 0));
		}
		for (j = 0; j<n; j++) {
			p m = pq.top();
			pq.pop();
			m.first += b[(i + j) % n] / 2;
			++m.second;
			t = max(t, m.second);
			pq.push(m);
		}
		ans = min(ans, t);
	}
	cout << ans << endl;
	return 0;
}

0