結果

問題 No.9 モンスターのレベル上げ
ユーザー mbanmban
提出日時 2017-01-15 00:36:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,300 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 74,304 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 10:48:30
合計ジャッジ時間 4,547 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 331 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 90 ms
4,376 KB
testcase_06 AC 30 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 40 ms
4,380 KB
testcase_09 AC 321 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 263 ms
4,380 KB
testcase_12 AC 259 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 323 ms
4,376 KB
testcase_15 AC 293 ms
4,380 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 151 ms
4,376 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<queue> 

using namespace std;

int n;
int *a, *b;
int i,j;
int ans = 1 << 16;

void scan();
void solve();
int cnt(int index);
void write();

struct monstar
{
	int battle;
	int level;
};

struct temp :less<monstar>
{
	bool operator()(const monstar &a, const monstar &b) {
		if (a.level != b.level) {
			return a.level > b.level;
		}
		else
		{
			return a.battle < b.battle;
		}
	}
};

int main(void) {
	scan();
	solve();
	write();
	return 0;
}

void scan() {
	cin >> n;
	a = new int[n];
	b = new int[n];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < n; i++) {
		cin >> b[i];
	}
}

void solve() {
	for (j = 0; j < n; j++) {
		int a = cnt(j);
		if (a < ans) {
			ans = a;
		}
	}
}

void write() {
	cout << ans << endl;
}

int cnt(int index) {
	priority_queue<monstar, vector<monstar>, temp> q;
	for (i = 0; i < n; i++) {
		struct monstar add = { 0,a[i] };
		q.push(add);
	}
	for (i = index; i < n; i++) {
		monstar cp = q.top();
		q.pop();
		cp.battle++;
		cp.level += b[i] / 2;
		q.push(cp);
	}
	for (i = 0; i < index; i++) {
		monstar cp = q.top();
		q.pop();
		cp.battle++;
		cp.level += b[i] / 2;
		q.push(cp);
	}
	int max = 0;
	for (i = 0; i < n; i++) {
		monstar m = q.top();
		q.pop();
		if (max < m.battle) {
			max = m.battle;
		}
	}
	return max;
}
0