結果

問題 No.4 おもりと天秤
コンテスト
ユーザー taba
提出日時 2016-04-12 23:25:10
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 71 ms / 5,000 ms
+ 40µs
コード長 330 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 67 ms
コンパイル使用メモリ 80,896 KB
実行使用メモリ 82,304 KB
最終ジャッジ日時 2026-07-18 04:57:49
合計ジャッジ時間 3,039 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n=input()
w=sorted(map(int,raw_input().split()))[::-1]
s=sum(w)
if s&1:
	print"impossible"
	exit()
s/=2
if s in w:
	print"possible"
	exit()
t=[0]*(s+1)
for i in range(n):
	nt=t[:]
	tw=w[i]
	for j in range(s):
		if j+tw<=s and t[j]+tw<=s:
			nt[j+tw]=max(t[j+tw],t[j]+tw)
	t=nt
#print t
#print s
print["im",""][s==t[-1]]+"possible"
0