結果

問題 No.4 おもりと天秤
ユーザー nsd_fb
提出日時 2015-02-19 03:50:50
言語 Python2
(2.7.18)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 338 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-26 09:07:35
合計ジャッジ時間 1,602 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    N = input()
    W = map(int, raw_input().split())

    S = sum(W)

    if S & 1:
        return False

    can = [False] * (S + 1)
    can[0] = True

    for w in W:
        for i in xrange(S - w, -1, -1):
            can[i + w] = can[i + w] or can[i]

    return can[S / 2]

print 'possible' if solve() else 'impossible'
0