結果

問題 No.4 おもりと天秤
ユーザー shimonohnishishimonohnishi
提出日時 2024-06-09 17:48:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 294 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 58,496 KB
最終ジャッジ日時 2024-12-30 13:59:55
合計ジャッジ時間 2,482 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = list(map(int, input().split()))
S = sum(W)
if S % 2 != 0:
    print('impossible')
else:
    S = S // 2
    dp = [0] * (S + 1)
    dp[0] = 1
    for w in W:
        for i in range(S, w - 1, -1):
            dp[i] |= dp[i - w]
    print('possible' if dp[S] else 'impossible')
0