結果

問題 No.4 おもりと天秤
ユーザー AEn
提出日時 2022-05-16 16:05:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 389 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 83,840 KB
最終ジャッジ日時 2024-09-14 08:12:26
合計ジャッジ時間 2,417 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

sm = sum(W)
if sm%2 == 1:
    print('impossible')
    exit()
dp = [[True]+[False]*sm for _ in range(N)]
dp[0][W[0]] = True
for i in range(1, N):
    for j in range(sm+1):
        dp[i][j] = dp[i-1][j]
        if j - W[i] >= 0:
            dp[i][j] = dp[i-1][j-W[i]]
if dp[-1][sm//2]:
    print('possible')
else:
    print('impossible')
0