結果

問題 No.231 めぐるはめぐる (1)
ユーザー zazaboonzazaboon
提出日時 2015-08-07 19:18:07
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,164 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 25,668 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 05:53:20
合計ジャッジ時間 2,018 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
int sum_exp(int h,int h_exp[1000],int max_i[6])
{
	int i,sum=0;
	for(i=0;i<h;i++)
	{
		sum += h_exp[max_i[i]];
	}
	return sum;
}
int max_i_exp(int n,int exp[1000])
{
	int i,max,max_i=0;
	max=exp[0];
	for(i=0;i<n;i++)
	{
		if(exp[i]>max)
		{
			max = exp[i];
			max_i = i;
		}
	}
	return max_i;
}
int main (void)
{
	int n,g[1000],d[1000],i,h_exp[1000],h_exp_c[1000],h=6,d_exp=30000,j=0,sum=0,max_i[6];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&g[i]);
		scanf("%d",&d[i]);
		h_exp[i] = g[i] - (d_exp * d[i]);
		h_exp_c[i]=h_exp[i];
	}
	for(i=0;i<h;i++)
	{
		max_i[i] = max_i_exp(n,h_exp_c);
		h_exp_c[max_i[i]]-=1000000;
	}
	if((h_exp[max_i[0]]*h)>=d_exp*100)
	{
		printf("YES\n");
		sum = sum_exp(h,h_exp,max_i);		
		while(sum<=d_exp*100&&j<3)
		{
			max_i[5-j]=max_i[j];
			j++;
			sum = sum_exp(h,h_exp,max_i);
		}
		j=0;
		while(sum<=d_exp*100&&j<2)
		{
			max_i[2+j]=max_i[j];
			j++;
			sum = sum_exp(h,h_exp,max_i);
		}
		j=0;
		while(sum<=d_exp*100&&j<5)
		{
			max_i[j]=max_i[0];
			j++;
			sum = sum_exp(n,h_exp,max_i);
		}
		for(i=0;i<h;i++)
		{
			printf("%d\n",(max_i[i]+1));
		}
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}
0