結果

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

ソースコード

diff #

N = input()
W = map(int,raw_input().split())
S = sum(W)
if S&1:
	print "impossible"
else:
	S /= 2
	dp = [False]*(S+101)
	dp[0] = True
	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