結果

問題 No.4 おもりと天秤
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-04-05 10:26:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 272 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 75,960 KB
最終ジャッジ日時 2023-08-28 22:31:38
合計ジャッジ時間 3,529 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,468 KB
testcase_01 AC 76 ms
75,584 KB
testcase_02 AC 78 ms
75,432 KB
testcase_03 AC 78 ms
75,552 KB
testcase_04 AC 78 ms
75,484 KB
testcase_05 AC 81 ms
75,492 KB
testcase_06 AC 77 ms
75,240 KB
testcase_07 AC 82 ms
75,484 KB
testcase_08 AC 81 ms
75,332 KB
testcase_09 AC 82 ms
75,412 KB
testcase_10 AC 82 ms
75,692 KB
testcase_11 AC 77 ms
75,592 KB
testcase_12 AC 79 ms
75,236 KB
testcase_13 AC 79 ms
75,204 KB
testcase_14 AC 78 ms
75,484 KB
testcase_15 AC 76 ms
75,204 KB
testcase_16 AC 76 ms
75,236 KB
testcase_17 AC 77 ms
75,084 KB
testcase_18 AC 82 ms
75,908 KB
testcase_19 AC 83 ms
75,960 KB
testcase_20 AC 81 ms
75,496 KB
testcase_21 AC 82 ms
75,908 KB
testcase_22 AC 82 ms
75,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
W = list(map(int,input().split()))
M = 10**4
dp = [0]*(M+5)

dp[0] = 1
for w in W:
    for i in range(M)[::-1]:
        if dp[i] and i+w <= M:
            dp[i+w] = 1
s = sum(W)
if s%2 == 0 and dp[s//2]:
    print("possible")
else:
    print("impossible")
0