結果

問題 No.4 おもりと天秤
コンテスト
ユーザー pekempey
提出日時 2015-08-23 12:11:05
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 66 ms / 5,000 ms
+ 109µs
コード長 331 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 65 ms
コンパイル使用メモリ 81,152 KB
実行使用メモリ 82,048 KB
最終ジャッジ日時 2026-07-17 19:32:37
合計ジャッジ時間 3,337 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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