結果

問題 No.9 モンスターのレベル上げ
ユーザー mbanmban
提出日時 2017-01-15 02:14:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,149 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 76,328 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 10:54:01
合計ジャッジ時間 3,482 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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> 
#include<cstdio>
using namespace std;

int n;
int *a, *b;
int i,j,k;
int ans = 99999999;

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

struct monstar
{
	int battle;
	int level;
};

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

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

void solve() {
	int ans = 9999999;
	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<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq;
	for (i = 0; i < n; i++){
		pq.push(pair<int,int>(a[i],0));
	}
	for (i = index; i < n; i++) {
		pair<int, int>p = pq.top();
		pq.pop();
		p.first += b[i] / 2;
		p.second++;
		pq.push(p);
	}
	for (i = 0; i < index; i++) {
		pair<int, int>p = pq.top();
		pq.pop();
		p.first += b[i] / 2;
		p.second++;
		pq.push(p);
	}
	int max = 0;
	for (i = 0; i < n; i++) {
		if (max < pq.top().second) {
			max = pq.top().second;
		}
		pq.pop();
	}
	return max;
}
0