結果

問題 No.4 おもりと天秤
ユーザー satama123
提出日時 2023-11-11 23:28:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 63,232 KB
最終ジャッジ日時 2024-09-26 02:55:43
合計ジャッジ時間 2,404 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
W = list(map(int, input().split()))
S = sum(W)

if S & 1 : exit(print("impossible"))
S //= 2
dp = [[False for _ in range(S + 1)] for _ in range(N + 1)]
dp[0][0] = True

for i in range(N):
    w = W[i]

    for s in range(S):
        if not dp[i][s] : continue
        if w + s > S : break
        dp[i + 1][s + w] = True
        dp[i + 1][s] = True

if dp[N][S] : print("possible")
else : print("impossible")
0