結果

問題 No.4 おもりと天秤
ユーザー zombietan
提出日時 2016-05-07 14:36:19
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 66 ms / 5,000 ms
コード長 361 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-26 09:33:10
合計ジャッジ時間 1,772 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
w = [int(x) for x in input().split()]
if sum(w)%2 != 0:
    print('impossible')
else:
    hs = sum(w)//2
    m = set([0])
    for i in w:
        nm = set(m)
        for a in m:
            sw = i + a
            if sw == hs:
                print('possible')
                quit()
            nm.add(sw)
        m = nm
    print('impossible')
0