結果

問題 No.9 モンスターのレベル上げ
ユーザー mbanmban
提出日時 2017-01-15 00:17:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,298 bytes
コンパイル時間 661 ms
コンパイル使用メモリ 75,080 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-08-23 10:47:29
合計ジャッジ時間 4,478 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
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 (j < ans) {
			ans = j;
		}
	}
}

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