結果

問題 No.4 おもりと天秤
ユーザー pekempeypekempey
提出日時 2015-08-23 12:11:05
言語 Python2
(2.7.18)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 331 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 6,640 KB
実行使用メモリ 6,032 KB
最終ジャッジ日時 2023-09-08 16:24:25
合計ジャッジ時間 1,929 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,892 KB
testcase_01 AC 11 ms
5,868 KB
testcase_02 AC 13 ms
6,000 KB
testcase_03 AC 11 ms
5,964 KB
testcase_04 AC 13 ms
5,792 KB
testcase_05 AC 78 ms
5,872 KB
testcase_06 AC 11 ms
5,960 KB
testcase_07 AC 79 ms
5,860 KB
testcase_08 AC 11 ms
5,872 KB
testcase_09 AC 136 ms
5,880 KB
testcase_10 AC 92 ms
5,936 KB
testcase_11 AC 11 ms
6,000 KB
testcase_12 AC 11 ms
5,860 KB
testcase_13 AC 11 ms
5,864 KB
testcase_14 AC 11 ms
5,992 KB
testcase_15 AC 11 ms
6,032 KB
testcase_16 AC 11 ms
5,864 KB
testcase_17 AC 11 ms
6,032 KB
testcase_18 AC 75 ms
5,800 KB
testcase_19 AC 72 ms
5,900 KB
testcase_20 AC 72 ms
5,940 KB
testcase_21 AC 68 ms
5,892 KB
testcase_22 AC 69 ms
5,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, W = int(raw_input()), map(int, raw_input().split())
total = sum(W)

if total % 2 == 1:
	print 'impossible'
	exit()

half = total / 2
dp = [False] * (half + 1)
dp[0] = True

for i in xrange(N):
	for j in xrange(half, -1, -1):
		if j - W[i] >= 0:
			dp[j] |= dp[j - W[i]]

if dp[half]:
	print 'possible'
else:
	print 'impossible'
0