結果

問題 No.4 おもりと天秤
ユーザー ntuda
提出日時 2025-07-09 23:47:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 339 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 66,432 KB
最終ジャッジ日時 2025-07-09 23:47:57
合計ジャッジ時間 2,227 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = list(map(int,input().split()))
sum0 = sum(W)
if sum0 % 2 == 1:
    print("impossible")
    exit()
dp = [0] * (1 + sum0//2)
dp[0] = 1
for w in W:
    for j in reversed(range(sum0//2 - w + 1)):
        if dp[j] == 1:
            dp[j + w] = dp[j]
if dp[sum0//2] == 1:
    print("possible")
else:
    print("impossible")
0