Repository navigation
Expand file tree
/
Copy pathB. No Casino in the Mountains.py
More file actions
132 lines (113 loc) · 3.65 KB
/
Copy pathB. No Casino in the Mountains.py
File metadata and controls
132 lines (113 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
ImportType = InputType = ConstType = 1
DecoratorType = FunctinoType = 1
if ImportType:
import os
import sys
import random
import threading
from copy import deepcopy
from decimal import Decimal, getcontext
from random import randint, choice, shuffle
from types import GeneratorType
from functools import lru_cache, reduce
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from itertools import accumulate, combinations, permutations
from heapq import heapify, heappop, heappush, heappushpop
from typing import Generic, Iterable, Iterator, TypeVar, Union, List
from string import ascii_lowercase, ascii_uppercase, digits
from math import ceil, floor, sqrt, pi, factorial, gcd, log, log10, log2, inf
from sys import stdin, stdout, setrecursionlimit
from string import (
ascii_lowercase,
ascii_uppercase,
digits,
punctuation,
printable,
whitespace,
)
if InputType:
def input(): return sys.stdin.readline().rstrip("\r\n")
def I(): return input()
def II(): return int(input())
def MII(): return map(int, input().split())
def LI(): return list(input())
def LII(): return list(map(int, input().split()))
def GMI(): return map(lambda x: int(x) - 1, input().split())
def LGMI(): return list(map(lambda x: int(x) - 1, input().split()))
if FunctinoType:
class Math:
__slots__ = ["mod", "l", "fact", "inv"]
def __init__(self):
self.mod = mod = 10**9 + 7
self.l = l = 3 * 10**5 + 5
self.fact = fact = [1] * (l + 1)
self.inv = inv = [1] * (l + 1)
for i in range(1, l + 1):
fact[i] = fact[i - 1] * i % mod
inv[l] = pow(fact[l], mod - 2, mod)
for i in range(l - 1, -1, -1):
inv[i] = inv[i + 1] * (i + 1) % mod
def comb(self, n: int, r: int): # (Combination) CNR เลขจัดหมู่
return (self.fact[n] * self.inv[r] %
self.mod * self.inv[n - r] %
self.mod if n >= r >= 0 else 0)
def perm(self, n: int, r: int): # (Permutation) PNR เลขเรียงสับเปลี่ยน
return self.fact[n] * self.inv[n -
r] % self.mod if n >= r >= 0 else 0
# math_obj = Math()
# combination = math_obj.comb(5, 2) # คำนวณค่า C(5, 2) = 10
# permutation = math_obj.perm(5, 2) # คำนวณค่า P(5, 2) = 20
if ConstType:
MOD1, MOD9 = 10**9 + 7, 998244353
RD = random.randint(MOD1, MOD1 << 1)
Direction4 = [(0, 1), (0, -1), (1, 0), (-1, 0)] # ->, <-, v, ^
Direction8 = [
(0, 1),
(0, -1),
(1, 0),
(-1, 0),
(1, 1),
(1, -1),
(-1, 1),
(-1, -1),
] # ->, <-, v, ^, ↘, ↙, ↗, ↖
Y, N = "Yes", "No"
A, B = "Alice", "Bob"
def solve():
n, k = MII()
a = LII()
tmp = 0
ans = 0
i = 0
while i < n:
if a[i] == 0:
tmp += 1
else:
tmp = 0
if tmp == k:
ans += 1
tmp = 0
i += 1
i += 1
print(ans)
# def solve():
# n, k = MII()
# a = LII()
# tmp = 0
# ans = 0
# for i in range(n):
# if a[i] == 0:
# tmp += 1
# else:
# tmp = 0
# if tmp == k:
# ans += 1
# tmp = 0
# if i + 1 < n:
# a[i + 1] = 1
# print(ans)
if __name__ == "__main__":
TEST = II()
for _ in range(TEST):
solve()