結果

問題 No.9 モンスターのレベル上げ
ユーザー myantamyanta
提出日時 2017-04-30 09:06:03
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,126 bytes
コンパイル時間 892 ms
コンパイル使用メモリ 53,336 KB
実行使用メモリ 7,048 KB
最終ジャッジ日時 2023-10-11 23:30:25
合計ジャッジ時間 7,844 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<vector>
#include<algorithm>


using namespace std;


struct p_t
{
	int l, x;
};


bool p_cmp(p_t& l, p_t& r)
{
	if(l.l!=r.l) return (l.l<r.l);
	return (l.x<r.x);
}


int calc(vector<p_t>& a, vector<int>& b, int start, int limit)
{
	int max;

	max=0;
	for(unsigned i=0;i<b.size();i++)
	{
		sort(a.begin(), a.end(), p_cmp);
/*
for(unsigned j=0;j<a.size();j++) printf("%d[%d] ", a[j].l, a[j].x);
printf("\n");
*/
		a[0].l+=b[(start+i)%b.size()];
		a[0].x++;
		if(max<a[0].x)
		{
			max=a[0].x;
			if(max>=limit) break;
		}
	}
	return max;
}


void min_u(int& m, int v)
{
	if(m>v) m=v;
}


int solve(vector<p_t>& a, vector<int>& b)
{
	vector<p_t> wa;
	vector<int> wb;
	int i, r=0;

	r=b.size();
	for(i=0;i<b.size();i++)
	{
		wa=a;
		wb=b;
		min_u(r, calc(wa, wb, i, a.size()));
	}
	return r;
}


int main(void)
{
	int n, i;
	vector<p_t> a;
	vector<int> b;

	while(scanf("%d", &n)==1)
	{
		a.clear();
		a.resize(n);
		b.resize(n);
		for(i=0;i<n;i++) scanf("%d", &a[i].l);
		for(i=0;i<n;i++) scanf("%d", &b[i]), b[i]/=2;

		sort(a.begin(), a.end(), p_cmp);

		printf("%d\n", solve(a, b));
	}

	return 0;
}
0