結果

問題 No.1861 Required Number
ユーザー hir355hir355
提出日時 2022-03-04 22:02:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 124 ms / 2,500 ms
コード長 460 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 77,932 KB
最終ジャッジ日時 2023-09-26 03:31:54
合計ジャッジ時間 15,957 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
71,676 KB
testcase_01 AC 95 ms
71,372 KB
testcase_02 AC 96 ms
71,684 KB
testcase_03 AC 124 ms
77,892 KB
testcase_04 AC 116 ms
77,904 KB
testcase_05 AC 99 ms
71,500 KB
testcase_06 AC 99 ms
71,636 KB
testcase_07 AC 103 ms
71,664 KB
testcase_08 AC 100 ms
71,764 KB
testcase_09 AC 102 ms
71,740 KB
testcase_10 AC 101 ms
71,612 KB
testcase_11 AC 100 ms
71,376 KB
testcase_12 AC 100 ms
71,680 KB
testcase_13 AC 98 ms
71,628 KB
testcase_14 AC 97 ms
71,476 KB
testcase_15 AC 96 ms
71,564 KB
testcase_16 AC 99 ms
71,484 KB
testcase_17 AC 99 ms
71,688 KB
testcase_18 AC 98 ms
71,680 KB
testcase_19 AC 98 ms
71,468 KB
testcase_20 AC 98 ms
71,632 KB
testcase_21 AC 98 ms
71,748 KB
testcase_22 AC 98 ms
71,772 KB
testcase_23 AC 96 ms
71,632 KB
testcase_24 AC 109 ms
77,664 KB
testcase_25 AC 116 ms
77,696 KB
testcase_26 AC 112 ms
77,644 KB
testcase_27 AC 115 ms
77,752 KB
testcase_28 AC 113 ms
77,700 KB
testcase_29 AC 110 ms
77,892 KB
testcase_30 AC 107 ms
77,784 KB
testcase_31 AC 113 ms
77,836 KB
testcase_32 AC 110 ms
77,636 KB
testcase_33 AC 114 ms
77,752 KB
testcase_34 AC 113 ms
77,776 KB
testcase_35 AC 116 ms
77,836 KB
testcase_36 AC 111 ms
77,616 KB
testcase_37 AC 109 ms
77,648 KB
testcase_38 AC 113 ms
77,928 KB
testcase_39 AC 115 ms
77,724 KB
testcase_40 AC 113 ms
77,668 KB
testcase_41 AC 113 ms
77,876 KB
testcase_42 AC 114 ms
77,932 KB
testcase_43 AC 108 ms
77,832 KB
testcase_44 AC 96 ms
71,620 KB
04_evil_1.txt MLE -
04_evil_2.txt MLE -
04_evil_3.txt MLE -
04_evil_4.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
dp1 = 1
res1 = [1] * (n + 1)
dp2 = 1 << k
res2 = [1 << k] * (n + 1)
mask = (1 << (k + 1)) - 1
for i in range(n):
    dp1 |= dp1 << a[i]
    dp1 &= mask
    dp2 |= dp2 >> a[n - i - 1]
    res1[i + 1] = dp1
    res2[n - i - 1] = dp2
ans = 0
for i in range(n):
    if res1[i] & res2[i + 1]:
        ans += 1
if res2[0] & 1:
    print(n - ans)
else:
    print(-1)
0