結果

問題 No.4 おもりと天秤
ユーザー DialBird
提出日時 2019-07-20 10:44:48
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 392 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-12-29 17:25:23
合計ジャッジ時間 1,822 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

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