結果

問題 No.4 おもりと天秤
ユーザー るさ
提出日時 2018-06-03 17:31:02
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 400 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-30 09:25:21
合計ジャッジ時間 3,377 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
w=list(map(int,input().split()))
hw=int(sum(w)/2)
if hw*2!=sum(w):
    print("impossible")
else:
    table=[0 for i in range(hw+1)]
    table[0]=1
    for i in w:
        for j in range(hw+1):
            try:
                table[j+i]=max(table[j+i],table[j])
            except:
                pass
    if table[-1]==1:
       print("possible")
    else:
       print("impossible")
0