結果

問題 No.9 モンスターのレベル上げ
ユーザー hotpepsihotpepsi
提出日時 2015-03-04 00:23:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 460 ms / 5,000 ms
コード長 924 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 74,396 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 03:41:47
合計ジャッジ時間 5,622 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 460 ms
4,380 KB
testcase_03 AC 364 ms
4,380 KB
testcase_04 AC 192 ms
4,376 KB
testcase_05 AC 126 ms
4,380 KB
testcase_06 AC 43 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 57 ms
4,376 KB
testcase_09 AC 445 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 384 ms
4,380 KB
testcase_12 AC 304 ms
4,380 KB
testcase_13 AC 210 ms
4,380 KB
testcase_14 AC 449 ms
4,380 KB
testcase_15 AC 405 ms
4,380 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 262 ms
4,380 KB
testcase_18 AC 220 ms
4,376 KB
testcase_19 AC 5 ms
4,380 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