結果

問題 No.4 おもりと天秤
ユーザー taisuke
提出日時 2023-02-19 18:06:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 379 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-20 17:03:41
合計ジャッジ時間 2,274 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
w = list(map(int, input().split()))
wsum = sum(w)
if wsum % 2 != 0:
    print("impossible")
    exit()

wmax = wsum // 2
dp = [False for j in range(wmax + 1)]
dp[0] = True

for i in range(1, n+1):
    for j in range(wmax + 1):
        if j >= w[i-1]:
            dp[j] = dp[j] or dp[j - w[i-1]]

ans = "possible" if dp[wmax] == True else "impossible"
print(ans)
0