結果

問題 No.4 おもりと天秤
ユーザー siganai
提出日時 2022-05-26 14:46:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 361 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 60,800 KB
最終ジャッジ日時 2024-09-20 15:00:15
合計ジャッジ時間 2,306 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
w = list(map(int,input().split()))
if sum(w) % 2:
    print('impossible')
else:
    dp = [0] * (sum(w) + 1)
    dp[0] = 1
    for i in range(n):
        for j in range(len(dp))[::-1]:
            if j - w[i] >= 0 and dp[j - w[i]]:
                dp[j] = 1
    if dp[sum(w) // 2]:
        print('possible')
    else:
        print('impossible')
0