結果

問題 No.4 おもりと天秤
ユーザー hokekiyoohokekiyoo
提出日時 2020-02-20 16:11:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 597 ms / 5,000 ms
コード長 439 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2024-04-17 06:24:55
合計ジャッジ時間 7,528 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
11,264 KB
testcase_01 AC 63 ms
11,392 KB
testcase_02 AC 117 ms
12,288 KB
testcase_03 AC 82 ms
11,776 KB
testcase_04 AC 113 ms
12,288 KB
testcase_05 AC 558 ms
19,584 KB
testcase_06 AC 41 ms
11,264 KB
testcase_07 AC 551 ms
19,584 KB
testcase_08 AC 570 ms
19,456 KB
testcase_09 AC 582 ms
19,456 KB
testcase_10 AC 551 ms
19,584 KB
testcase_11 AC 69 ms
11,520 KB
testcase_12 AC 48 ms
11,136 KB
testcase_13 AC 48 ms
11,136 KB
testcase_14 AC 53 ms
11,136 KB
testcase_15 AC 48 ms
11,264 KB
testcase_16 AC 78 ms
11,648 KB
testcase_17 AC 73 ms
11,520 KB
testcase_18 AC 597 ms
19,584 KB
testcase_19 AC 552 ms
19,584 KB
testcase_20 AC 559 ms
19,456 KB
testcase_21 AC 583 ms
19,584 KB
testcase_22 AC 579 ms
19,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

wmax = 11000
dp = [[False] * wmax for i in range(N+1)]
dp[0][0] = True
for i in range(N):
    dp[i+1][:] = dp[i][:]
    w = Ws[i]
    for j in range(wmax):
        if w + j >= wmax: continue
        dp[i+1][j+w] = dp[i][j+w] or dp[i][j]

W_sum = sum(Ws)
if W_sum % 2  == 1:
    print("impossible")
elif dp[N][W_sum//2]:
    print("possible")
else:
    print("impossible")
# print(dp)
0