結果

問題 No.4 おもりと天秤
ユーザー KudeKude
提出日時 2020-09-03 07:01:18
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 291 bytes
コンパイル時間 3,260 ms
コンパイル使用メモリ 86,528 KB
実行使用メモリ 76,164 KB
最終ジャッジ日時 2023-08-14 17:25:58
合計ジャッジ時間 3,293 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,320 KB
testcase_01 AC 72 ms
71,352 KB
testcase_02 AC 75 ms
75,824 KB
testcase_03 AC 73 ms
76,008 KB
testcase_04 AC 78 ms
76,084 KB
testcase_05 AC 82 ms
76,024 KB
testcase_06 AC 72 ms
71,380 KB
testcase_07 AC 80 ms
76,056 KB
testcase_08 AC 70 ms
71,328 KB
testcase_09 AC 79 ms
75,640 KB
testcase_10 AC 81 ms
75,972 KB
testcase_11 AC 72 ms
71,280 KB
testcase_12 AC 71 ms
71,224 KB
testcase_13 AC 71 ms
71,412 KB
testcase_14 AC 70 ms
71,140 KB
testcase_15 AC 69 ms
71,284 KB
testcase_16 AC 70 ms
71,276 KB
testcase_17 AC 70 ms
71,188 KB
testcase_18 AC 78 ms
76,160 KB
testcase_19 AC 80 ms
76,164 KB
testcase_20 AC 78 ms
75,856 KB
testcase_21 AC 80 ms
75,996 KB
testcase_22 AC 80 ms
75,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
w = list(map(int, input().split()))
m = sum(w)
ok = False
if m % 2 == 0:
    m //= 2
    dp = [False] * (m + 1)
    dp[0] = True
    for wi in w:
        for i in range(m - wi, -1, -1):
            dp[i + wi] |= dp[i]
    ok = dp[m]
print('possible' if ok else 'impossible')
0