結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-04-12 23:24:44 |
言語 | Python2 (2.7.18) |
結果 |
WA
|
実行時間 | - |
コード長 | 328 bytes |
コンパイル時間 | 109 ms |
コンパイル使用メモリ | 7,040 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-04 06:05:44 |
合計ジャッジ時間 | 2,522 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 20 |
ソースコード
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"