結果

問題 No.9 モンスターのレベル上げ
ユーザー OnjuOnju
提出日時 2015-01-31 17:56:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,246 bytes
コンパイル時間 1,537 ms
コンパイル使用メモリ 61,952 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-05 08:35:11
合計ジャッジ時間 46,644 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

//No.9 モンスターのレベル上げ
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <cstring>
#define N_MAX 1500
using namespace std;

typedef struct
{
	int Level;
	int Count;
} FM;

bool compFm(const FM& x, const FM& y)
{
	if (x.Level - y.Level)
		return x.Level < y.Level;
	return x.Count < y.Count;
}

bool compC(const FM& x, const FM& y)
{
	return x.Count > y.Count;
}

void swap(FM& x, FM& y)
{
	FM t = y;
	y = x;
	x = t;
}

void resort(FM* fm)
{
	for (int i = 0; i < N_MAX; ++i)
		if (fm[i].Level > fm[i + 1].Level && fm[i].Count > fm[i + 1].Count)
			swap(fm[i], fm[i + 1]);
}

int main()
{
	int N;
	FM A[N_MAX], AA[N_MAX];
	int B[N_MAX];
	int ans = INT_MAX;
	cin >> N;

	for (int i = 0; i < N; ++i)
		cin >> A[i].Level;
	for (int i = 0; i < N; ++i)
		cin >> B[i];
	sort(A, A + N - 1, compFm);

	////最初の敵選択ループ
	for (int f = 0; f < N; ++f)
	{
		std::memcpy(AA, A, sizeof(FM)*N);
		//memcpy_s(AA, sizeof(AA), A, sizeof(FM)*N);
		for (int i = 0; i < N; ++i)
		{
			int t = (f + i) % N;
			//sort(AA, AA + N - 1, compFm);
			AA[0].Level += B[t] / 2;
			++(AA[0].Count);
			resort(AA);
		}
		sort(AA, AA + N - 1, compC);
		if (AA[0].Count < ans)
			ans = AA[0].Count;
	}

	cout << ans;

	return 0;
}
0