結果

問題 No.9 モンスターのレベル上げ
ユーザー hotpepsihotpepsi
提出日時 2015-03-04 00:23:16
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 458 ms / 5,000 ms
コード長 924 bytes
コンパイル時間 526 ms
使用メモリ 6,952 KB
最終ジャッジ日時 2023-01-21 14:21:55
合計ジャッジ時間 5,682 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
6,952 KB
testcase_01 AC 2 ms
4,900 KB
testcase_02 AC 458 ms
4,904 KB
testcase_03 AC 363 ms
4,904 KB
testcase_04 AC 192 ms
6,948 KB
testcase_05 AC 125 ms
4,900 KB
testcase_06 AC 42 ms
4,904 KB
testcase_07 AC 2 ms
4,908 KB
testcase_08 AC 57 ms
4,900 KB
testcase_09 AC 444 ms
4,904 KB
testcase_10 AC 1 ms
4,900 KB
testcase_11 AC 382 ms
4,900 KB
testcase_12 AC 304 ms
4,900 KB
testcase_13 AC 210 ms
4,900 KB
testcase_14 AC 445 ms
4,904 KB
testcase_15 AC 405 ms
4,900 KB
testcase_16 AC 8 ms
6,948 KB
testcase_17 AC 262 ms
6,952 KB
testcase_18 AC 218 ms
4,904 KB
testcase_19 AC 5 ms
4,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <queue>

using namespace std;

typedef vector<int> IntVec;
typedef pair<int, int> II;
typedef priority_queue<II> Queue;

int main(int argc, char *argv[])
{
	string s;
	getline(cin, s);
	int N = atoi(s.c_str());
	IntVec A(N), B(N);
	{
		getline(cin, s);
		stringstream ss(s);
		for (int i = 0; i < N; ++i) {
			ss >> A[i];
		}
	}
	{
		getline(cin, s);
		stringstream ss(s);
		for (int i = 0; i < N; ++i) {
			ss >> B[i];
		}
	}
	int ans = 1 << 30;
	for (int i = 0; i < N; ++i) {
		Queue q;
		for (int j = 0; j < N; ++j) {
			q.push(II(-A[j], 0));
		}
		for (int k = 0; k < N; ++k) {
			II x = q.top();
			q.pop();
			x.first -= B[(i + k) % N] / 2;
			x.second -= 1;
			q.push(x);
		}
		int m = 0;
		while (q.size()) {
			II x = q.top();
			q.pop();
			m = max(m, -x.second);
		}
		ans = min(ans, m);
	}
	cout << ans << endl;
	return 0;
}
0