結果

問題 No.231 めぐるはめぐる (1)
ユーザー pengin_2000pengin_2000
提出日時 2020-02-22 03:05:05
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 798 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 31,616 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 19:39:10
合計ジャッジ時間 2,329 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<stdio.h>
int min(int a, int b)
{
	if (a < b)
		return a;
	else
		return b;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int g[1003], d[1003];
	for (i = 0; i < n; i++)
		scanf("%d %d", &g[i], &d[i]);
	for (i = 0; i < n; i++)
		g[i] -= 30000 * d[i];
	int c[1003];
	for (i = 0; i < n; i++)
		c[i] = i;
	for (i = 0; i < n - 1; i++)
	{
		if (g[c[i]] < g[c[i + 1]])
		{
			c[i] ^= c[i + 1];
			c[i + 1] ^= c[i];
			c[i] ^= c[i + 1];
			if (i > 0)
				i -= 2;
		}
	}
	if (g[c[0]] * 6 < 300000)
	{
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	int s = 300000;
	int j = 0;
	for (i = 0; i < 6; i++)
	{
		if (g[c[0]] * (6 - i - 1) + g[c[j]] >= s)
		{
			printf("%d\n", j + 1);
			s -= g[c[j]];
			j = min(n - 1, j + 1);
		}
		else
		{
			printf("1\n");
			s -= g[c[0]];
		}
	}
	return 0;
}
0