結果

問題 No.4 おもりと天秤
ユーザー Tawara
提出日時 2015-09-12 16:35:06
言語 Python2
(2.7.18)
結果
AC  
実行時間 95 ms / 5,000 ms
コード長 233 bytes
コンパイル時間 40 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-26 09:17:37
合計ジャッジ時間 1,512 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
W = map(int,raw_input().split())
S = sum(W)
if S&1:
	print "impossible"
else:
	S /= 2
	dp = [0]*(S+101)
	dp[0] = 1
	for w in W:
		for i in range(S-1,-1,-1):
			dp[i+w] += dp[i]
	print "possible" if dp[S] else "impossible"
0