結果

問題 No.4 おもりと天秤
ユーザー bellangeldindonbellangeldindon
提出日時 2019-05-15 15:33:19
言語 Python2
(2.7.18)
結果
AC  
実行時間 229 ms / 5,000 ms
コード長 444 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 6,712 KB
実行使用メモリ 14,548 KB
最終ジャッジ日時 2023-10-12 02:06:48
合計ジャッジ時間 3,902 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,952 KB
testcase_01 AC 11 ms
5,864 KB
testcase_02 AC 14 ms
5,968 KB
testcase_03 AC 12 ms
5,904 KB
testcase_04 AC 15 ms
6,016 KB
testcase_05 AC 201 ms
10,700 KB
testcase_06 AC 11 ms
5,872 KB
testcase_07 AC 208 ms
10,676 KB
testcase_08 AC 12 ms
6,056 KB
testcase_09 AC 229 ms
14,548 KB
testcase_10 AC 228 ms
11,240 KB
testcase_11 AC 12 ms
6,028 KB
testcase_12 AC 11 ms
5,948 KB
testcase_13 AC 11 ms
6,064 KB
testcase_14 AC 12 ms
5,952 KB
testcase_15 AC 11 ms
5,952 KB
testcase_16 AC 11 ms
5,956 KB
testcase_17 AC 11 ms
5,936 KB
testcase_18 AC 157 ms
10,300 KB
testcase_19 AC 184 ms
10,272 KB
testcase_20 AC 183 ms
10,228 KB
testcase_21 AC 174 ms
9,848 KB
testcase_22 AC 180 ms
9,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(raw_input())
W = map(int, raw_input().split())
sum = 0
for i in range(0, N):
	sum += W[i]
if sum % 2 == 1: print 'impossible'
else:
	dp = []
	for i in range(0, N+1):
		lst = []
		for j in range(0, sum+1):
			lst.append(False)
		dp.append(lst)
	dp[0][0] = True
	for i in range(0, N):
		for j in range(0, sum+1):
			if dp[i][j]:
				dp[i+1][j] = True
				dp[i+1][j+W[i]] = True
	if dp[N][sum/2]: print 'possible'
	else: print 'impossible'
0