結果

問題 No.4 おもりと天秤
ユーザー mkawa2
提出日時 2019-04-18 16:36:56
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 333 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-09-22 09:19:16
合計ジャッジ時間 1,750 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
vs=list(map(int,input().split()))
ws=set([0])
total=sum(vs)
if total%2:
    print("impossible")
    exit()
nws = ws.copy()
for v in vs:
    for w in nws:
        if w+v==total//2:
            print("possible")
            exit()
        elif w+v<total//2:
            ws.add(w+v)
    nws=ws.copy()
print("impossible")
0