結果

問題 No.4 おもりと天秤
ユーザー fmhrfmhr
提出日時 2015-04-22 16:47:23
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 110 ms / 5,000 ms
コード長 281 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 10,552 KB
実行使用メモリ 8,344 KB
最終ジャッジ日時 2023-09-08 16:14:34
合計ジャッジ時間 2,103 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,240 KB
testcase_01 AC 16 ms
8,204 KB
testcase_02 AC 17 ms
7,924 KB
testcase_03 AC 16 ms
8,276 KB
testcase_04 AC 17 ms
8,292 KB
testcase_05 AC 97 ms
8,244 KB
testcase_06 AC 15 ms
8,300 KB
testcase_07 AC 104 ms
8,336 KB
testcase_08 AC 17 ms
8,252 KB
testcase_09 AC 108 ms
8,168 KB
testcase_10 AC 110 ms
8,188 KB
testcase_11 AC 15 ms
8,204 KB
testcase_12 AC 16 ms
7,824 KB
testcase_13 AC 16 ms
8,204 KB
testcase_14 AC 15 ms
8,124 KB
testcase_15 AC 15 ms
8,244 KB
testcase_16 AC 16 ms
8,204 KB
testcase_17 AC 15 ms
8,208 KB
testcase_18 AC 79 ms
8,204 KB
testcase_19 AC 88 ms
8,164 KB
testcase_20 AC 87 ms
8,204 KB
testcase_21 AC 82 ms
8,344 KB
testcase_22 AC 88 ms
8,264 KB
権限があれば一括ダウンロードができます

ソースコード

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