結果

問題 No.1861 Required Number
ユーザー mkawa2mkawa2
提出日時 2022-03-04 21:59:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,500 ms
コード長 1,157 bytes
コンパイル時間 1,439 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 80,988 KB
最終ジャッジ日時 2023-09-26 03:31:11
合計ジャッジ時間 18,437 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,408 KB
testcase_01 AC 71 ms
71,424 KB
testcase_02 AC 70 ms
71,484 KB
testcase_03 AC 93 ms
76,568 KB
testcase_04 AC 80 ms
76,668 KB
testcase_05 AC 71 ms
71,252 KB
testcase_06 AC 71 ms
71,368 KB
testcase_07 AC 71 ms
71,456 KB
testcase_08 AC 72 ms
71,380 KB
testcase_09 AC 71 ms
71,092 KB
testcase_10 AC 69 ms
71,496 KB
testcase_11 AC 70 ms
71,440 KB
testcase_12 AC 69 ms
71,004 KB
testcase_13 AC 71 ms
71,256 KB
testcase_14 AC 68 ms
71,044 KB
testcase_15 AC 71 ms
71,532 KB
testcase_16 AC 71 ms
71,364 KB
testcase_17 AC 70 ms
71,504 KB
testcase_18 AC 70 ms
71,368 KB
testcase_19 AC 74 ms
71,384 KB
testcase_20 AC 72 ms
71,176 KB
testcase_21 AC 68 ms
71,364 KB
testcase_22 AC 69 ms
71,356 KB
testcase_23 AC 69 ms
71,440 KB
testcase_24 AC 79 ms
76,648 KB
testcase_25 AC 90 ms
80,728 KB
testcase_26 AC 79 ms
76,792 KB
testcase_27 AC 79 ms
76,392 KB
testcase_28 AC 81 ms
76,532 KB
testcase_29 AC 81 ms
76,560 KB
testcase_30 AC 79 ms
76,604 KB
testcase_31 AC 92 ms
80,808 KB
testcase_32 AC 80 ms
76,584 KB
testcase_33 AC 81 ms
76,664 KB
testcase_34 AC 82 ms
76,512 KB
testcase_35 AC 88 ms
80,444 KB
testcase_36 AC 81 ms
76,568 KB
testcase_37 AC 80 ms
76,532 KB
testcase_38 AC 87 ms
76,632 KB
testcase_39 AC 82 ms
76,432 KB
testcase_40 AC 91 ms
80,988 KB
testcase_41 AC 91 ms
80,772 KB
testcase_42 AC 84 ms
76,620 KB
testcase_43 AC 82 ms
76,680 KB
testcase_44 AC 71 ms
71,180 KB
04_evil_1.txt MLE -
04_evil_2.txt TLE -
04_evil_3.txt TLE -
04_evil_4.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

n, k = LI()
aa = LI()

mask = (1 << k+1)-1
ll = [1]
for a in aa:
    ll.append((ll[-1] << a & mask) | ll[-1])

if (ll[-1] >> k) == 0:
    print(-1)
    exit()

rr = [1 << k]
for a in aa[::-1]:
    rr.append(rr[-1] >> a | rr[-1])
rr.reverse()

# print(*[bin(a)[2:].zfill(k+1) for a in ll])
# print(*[bin(a)[2:].zfill(k+1) for a in rr])

ans = n
for i in range(n):
    if ll[i] & rr[i+1]:
        # pDB(i)
        ans -= 1

print(ans)
0