結果

問題 No.9 モンスターのレベル上げ
ユーザー pocaristpocarist
提出日時 2015-09-15 12:55:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 172 ms / 5,000 ms
コード長 887 bytes
コンパイル時間 844 ms
コンパイル使用メモリ 79,544 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 04:15:40
合計ジャッジ時間 2,938 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 172 ms
4,380 KB
testcase_03 AC 86 ms
4,380 KB
testcase_04 AC 73 ms
4,380 KB
testcase_05 AC 50 ms
4,376 KB
testcase_06 AC 16 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 20 ms
4,380 KB
testcase_09 AC 151 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 134 ms
4,376 KB
testcase_12 AC 115 ms
4,376 KB
testcase_13 AC 132 ms
4,380 KB
testcase_14 AC 148 ms
4,380 KB
testcase_15 AC 149 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 96 ms
4,376 KB
testcase_18 AC 81 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#include <tuple>
#include <algorithm>
#include <functional>
#include <set>
#include <limits>

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++) {
		int b;
		cin >> b;
		B[i] = b / 2;
	}
	typedef priority_queue<pair<int, int>, vector<pair<int, int>>, std::greater<pair<int, int>>> t;
	t orig;
	for (auto i : A) {
		orig.push(make_pair(i, 0));
	}

	int ans = numeric_limits<int>::max()/2;
	for (int i = 0; i < N; i++) {
		t q = orig;
		int tmp = 0;
		for (int j = 0; j < N; j++) {
			if (ans < tmp)
				break;
			int k = (i + j) % N;
			int a, n;
			tie(a, n) = q.top();
			q.pop();
			int b = B[k];
			q.push(make_pair(a + b, n + 1));
			tmp = max(tmp, n + 1);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}
0