結果

問題 No.4 おもりと天秤
ユーザー rodearodea
提出日時 2017-10-11 15:05:15
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 473 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 16:05:24
合計ジャッジ時間 2,464 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int n, i, j, ans, a[100], dp[100][5000] = { 0 };

int main(void)
{
	scanf("%d", &n);

	for (i = 0; i<n; i++)
	{
		scanf("%d", &a[i]);
		ans += a[i];
	}

	if (ans % 2 == 1) printf("impossible\n");

	dp[0][0] = 1;
	for (i = 0; i < n; ++i) 
	{
		for (j = 0; j <= 5000; ++j) 
		{
			if (dp[i][j] == 1) 
			{
				dp[i + 1][j + a[i]] = 1;
				dp[i + 1][j] = 1;
			}
		}
	}


	if (dp[n][ans/2]) printf("possible\n");
	else printf("impossible\n");

	return 0;
}
0