結果

問題 No.4 おもりと天秤
ユーザー taba
提出日時 2016-04-12 23:15:17
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 263 bytes
コンパイル時間 53 ms
コンパイル使用メモリ 6,784 KB
実行使用メモリ 6,912 KB
最終ジャッジ日時 2024-10-04 06:04:49
合計ジャッジ時間 2,124 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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