結果

問題 No.9 モンスターのレベル上げ
ユーザー Onju
提出日時 2015-01-31 18:17:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 1,212 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 61,196 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-23 04:37:15
合計ジャッジ時間 48,261 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 7 WA * 10 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

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;
	else
		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, int N)
{
	for (int i = 0; i < N-1; ++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;

	std::memset(A, 0, sizeof(A));

	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 , compFm);

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

	cout << ans;

	return 0;
}
0