結果

問題 No.4 おもりと天秤
コンテスト
ユーザー DialBird
提出日時 2019-07-20 10:44:48
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 30 ms / 5,000 ms
+ 203µs
コード長 392 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 54 ms
コンパイル使用メモリ 15,232 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2026-10-09 09:53:52
合計ジャッジ時間 1,845 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
    """ main """
    N = int(input())
    WS = list(map(int, input().split()))
    total = sum(WS)

    if total & 1 == 1:
        print('impossible')
        return

    half = total >> 1
    dp = set([0])

    for i in WS:
        dp |= set([i+j for j in dp])
        if half in dp:
            print('possible')
            break
    else:
        print('impossible')


main()
0