結果

問題 No.9 モンスターのレベル上げ
ユーザー tempura-samatempura-sama
提出日時 2016-04-12 17:03:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 225 ms / 5,000 ms
コード長 852 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 64,152 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 04:32:41
合計ジャッジ時間 3,206 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 225 ms
4,380 KB
testcase_03 AC 172 ms
4,376 KB
testcase_04 AC 88 ms
4,376 KB
testcase_05 AC 57 ms
4,376 KB
testcase_06 AC 20 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 26 ms
4,376 KB
testcase_09 AC 221 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 160 ms
4,376 KB
testcase_12 AC 111 ms
4,380 KB
testcase_13 AC 109 ms
4,376 KB
testcase_14 AC 220 ms
4,376 KB
testcase_15 AC 196 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 125 ms
4,380 KB
testcase_18 AC 101 ms
4,380 KB
testcase_19 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
using namespace std;

#ifndef INT_MAX
#define INT_MAX 0x7FFFFFFF
#endif

#define N 1500

int n;
int units[N];
int monsters[N];

int battle(int i)
{
	priority_queue<unsigned int, vector<unsigned int>, greater<unsigned int>> q;
	for ( int j = 0; j < n; j++ ) {
		q.push(units[j] << 16);
	}

	int max = 0;
	for ( int j = 0; j < n; j++ ) {
		int k = (i + j) % n;
		auto unit = q.top();
		q.pop();
		unit = unit + ((monsters[k] / 2) << 16) + 1;
		q.push(unit);
		max = max < (int)(unit & 0xFFFF) ? (unit & 0xFFFF) : max;
	}

	return max;
}

int main()
{
	cin >> n;
	for ( int i = 0; i < n; i++ ) {
		cin >> units[i];
	}
	for ( int i = 0; i < n; i++ ) {
		cin >> monsters[i];
	}

	int min = INT_MAX;
	for ( int i = 0; i < n; i++ ) {
		int t = battle(i);
		min = t < min ? t : min;
	}

	cout << min << endl;

	return 0;
}
0