結果

問題 No.4 おもりと天秤
ユーザー fmhr
提出日時 2015-04-22 16:47:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 281 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-26 09:10:50
合計ジャッジ時間 2,587 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [0] * 11000
sum = sum(W)
dp[0] = W[0]
for i in range(N):
    for j in range(sum-dp[i], -1, -1):
        if dp[j]:
            dp[j+W[i]] = 1
if sum%2 == 0 and dp[sum//2]:
    print('possible')
else:
    print('impossible')
0