結果

問題 No.4 おもりと天秤
ユーザー maatanbeta
提出日時 2017-05-12 15:50:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 391 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-26 10:16:47
合計ジャッジ時間 2,141 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
w = list(map(int, input().split()))
W = 0
for i in w:
    W += i / 2
if W == int(W):
    W = int(W)
    p = [False] * (W + 1)
    p[0] = True
    for i in w:
        for k in range(len(p)-1, -1, -1):
            if p[k] and k + i <= W:
                p[k+i] = True
    if p[W]:
        print("possible")
    else:
        print("impossible")
else:
    print("impossible")
0