description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.
Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o... | n = int(input())
s = input()
t = []
d = r = 0
for i in s:
t.append(i)
while len(t) != 1:
for i in range(len(t)):
if t[i] == "R" and d == 0:
r += 1
elif t[i] == "D" and r == 0:
d += 1
elif t[i] == "R" and d != 0:
d -= 1
t[i] = 0
else... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR... |
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.
Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o... | n = input()
a = input()
cnt = 0
while len(set(a)) == 2:
new_a = []
for i in range(len(a)):
if a[i] == "D":
if cnt >= 0:
new_a.append(a[i])
cnt += 1
else:
if cnt <= 0:
new_a.append(a[i])
cnt -= 1
a = new_a
print(a... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL... |
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.
Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o... | n = int(input())
raby = [x for x in input()]
numD = 0
numR = 0
flag = True
while flag:
cR = 0
cD = 0
for ind in range(len(raby)):
if raby[ind] == "D":
cD += 1
if numR == 0:
numD += 1
else:
raby[ind] = "N"
numR -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR... |
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.
Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o... | n = int(input())
s = input()
D, R = s.count("D"), s.count("R")
d, r = 0, 0
p = [1] * n
ans = 0
i = 0
while ans == 0:
if p[i]:
if s[i] == "D":
if d > 0:
d = d - 1
p[i] = 0
elif R > 0:
R -= 1
r = r + 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR ... |
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.
Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o... | n = int(input())
s = list(input())
r, d = 0, 0
while True:
t = 0
for i in range(n):
if s[i] == "D":
if d > 0:
s[i] = "0"
d -= 1
t += 1
else:
r += 1
if s[i] == "R":
if r > 0:
s[i] =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER VAR ... |
There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.
Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions o... | n = input()
a = input()
num = 0
while num < len(a):
b = "-"
num = 0
aa = ""
for i in a:
if b != i:
if num > 0:
num -= 1
else:
num = 1
b = i
aa += i
else:
num += 1
aa += i
a... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER VAR VAR ASSIGN VAR STRING FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = list(map(int, input().split()))
a = list(map(int, input().split()))
answer = 0
last_o = -r
used_o = -r
for i in range(n):
if a[i] == 1:
if i - used_o > 2 * (r - 1):
last_o = i
used_o = i
answer += 1
else:
last_o = i
elif i - used_o > 2 * (r ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | import sys
from itertools import accumulate
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [([c] * b) for i in range(a)]
def list3d(a, b, c, d):
return [[([d] * c) for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[([e] * d) for j in range(c)... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN FUNC_CALL ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
def oleft(i):
for j in range(min(i + r - 1, n - 1), max(-1, i - r), -1):
if a[j]:
return j + r
return 10**6
def oright(i):
for j in range(max(0, i - r + 1), min(i + r, n)):
if a[j]:
return j - r
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR VAR RETURN BIN_OP VAR VAR RETURN BIN_OP NUMBER NUMBER ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def heaters(n, r, arr):
ultimo = -1
con = 0
n = n - 1
while ultimo < n:
inicio = -1
encontrado = False
mid = max(-1, ultimo - r + 1)
for i in range(n, mid, -1):
if arr[i] == 1:
if i - r <= ultimo:
if i + r - 1 > inicio:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR NUMBER IF BIN_OP VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR ASSIGN ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
data = list(map(int, input().split()))
last = 0
ans = 0
while last < n:
save = -1
for i in range(max(0, last - r + 1), min(n, last + r)):
if data[i] == 1:
save = i
if save == -1:
ans = -1
break
else:
ans += 1
last = sav... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR NUMBER ASSIG... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
ans = last = 0
while True:
pos = -1
for i in range(last + r - 1, last - r, -1):
if i < 0 or i >= n:
continue
if a[i] == 1:
pos = i
break
if pos == -1:
print(-1)
exit()
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER E... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(lambda c: bool(int(c)), input().split()))
c = []
for i in range(n):
if a[i]:
c.append((max(i - r + 1, 0), min(i + r - 1, n - 1)))
if len(c) == 0:
print(-1)
else:
key = not (c[0][0] == 0 and c[-1][1] == n - 1)
for i in range(len(c) - 1):
if c[... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def ans(n, r, a):
a.insert(0, 0)
p, l, pl, cnt = 0, 0, 0, 0
for i in range(1, n + 1):
if i == p + r:
if a[i] == 1:
cnt += 1
pl = i
p = i + r - 1
elif l > pl:
cnt += 1
pl = i
p = l ... | FUNC_DEF EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMB... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
mb = True
fin = [(0) for i in range(n)]
ans = 0
for i in range(n):
if fin[i] == 0:
for pos in range(min(i + r - 1, n - 1), max(i - r + 1, 0) - 1, -1):
if a[pos] == 1:
ans += 1
for c in range(max(... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
cnt = 0
for i in range(n):
if a[i] == 1:
cnt += 1
le = max(0, i - r + 1)
ri = min(n, i + r)
for j in range(le, ri):
b[j] += 1
for i in b:
if i == 0:
print(-1)
quit()
for i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, k = map(int, input().split())
arr = list(map(int, input().split()))
new = [-1] * 1010
for i in range(len(arr)):
if arr[i] == 0:
continue
else:
for j in range(max(0, i - k + 1), min(n - 1, i + k - 1) + 1):
new[j] = max(new[j], i)
pos = 0
ans = 0
while pos < n:
if new[pos] == -1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP V... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
ind = []
for i in range(len(a)):
if a[i] == 1:
ind.append(i)
ans = [0] * len(a)
for i in ind:
for j in range(max(i - r, -1) + 1, min(i + r, len(a))):
ans[j] += 1
if 0 in ans:
print(-1)
else:
c = len(ind)
for i in in... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | a = input().split()
n, r = int(a[0]), int(a[1])
heaters = input().split()
def heat():
indexes_1 = []
for i in range(len(heaters)):
if heaters[i] == "1":
indexes_1.append(i)
if len(indexes_1) == 0:
return -1
elif indexes_1[0] - r + 1 > 0:
return -1
elif indexes_1... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBE... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def compute(n, r, array):
num_heaters = sum(array)
if num_heaters == 0:
return -1
heater_pos = set()
array_zeroed = [0] * n
for i, e in enumerate(array):
if e == 1:
heater_pos.add(i)
for j in range(max(0, i - r + 1), min(i + r, n)):
array_zeroe... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER FOR VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | from sys import stdin
input = stdin.readline
n, r = map(int, input().split())
arr = [int(x) for x in input().split()]
dp = [0] * n
for i in range(n):
if arr[i] == 1:
s = min(i + r - 1, n - 1)
e = max(i - r + 1, 0)
while s >= e and dp[s] == 0:
dp[s] = 1
s = s - 1
if d... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
heaters = list(map(int, input().split()))
count = 0
position = 0
last_seen_heater = -1
while position < n:
index = last_seen_heater + 1
while index < position + r and index < n:
if heaters[index] == 1:
last_seen_heater = index
index += 1
new_pos =... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | from sys import stdin, stdout
def get():
return stdin.readline().strip()
def getf(sp=" "):
return [int(i) for i in get().split(sp)]
def put(a, end="\n"):
stdout.write(str(a) + end)
def putf(a, sep=" ", end="\n"):
stdout.write(sep.join([str(i) for i in a]) + end)
def main():
n, r = getf()
... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF STRING RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_DEF STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_DEF STRING STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR F... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def get_max(x, y):
if x > y:
return x
else:
return y
def get_min(x, y):
if x < y:
return x
else:
return y
seg = []
n, r = map(int, input().split())
ar = list(map(int, input().split()))
for i in range(len(ar)):
if ar[i] == 0:
continue
seg.append((get_ma... | FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBE... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def mi():
return map(int, input().split())
n, r = mi()
a = list(mi())
def fun(n, a, r):
vis = [0] * n
i = 0
cnt = 0
for j in range(min(r, n)):
if a[j] == 1:
i = j
while i < n:
if vis[i] == 1 and vis[min(n, end + r) - 1] == 1:
break
if a[i] == 1... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR NUMBER VAR BI... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
enabled = [0] * n
ans = 0
i = 0
breaked = False
while i < n:
j = i + r - 1
heater = -1
while j >= i - r + 1:
if j >= 0 and j < n and a[j] == 1:
heater = j
break
j -= 1
if heater == -1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP VAR VAR NUMBER IF ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = [int(i) for i in input().split()]
j = 1
cur = 1
ans = 0
best_cur = 0
while cur <= n + 1 and j <= n:
if cur - r + 1 <= j and cur <= n:
if a[cur - 1] == 1:
best_cur = cur
elif best_cur != 0:
j = best_cur + r
ans += 1
best_cur = 0
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR IF VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
arr = [int(x) for x in input().split()]
c = 0
r = min(n, r)
f = False
i = 0
area = 0
while i < n:
if area >= n:
print(c)
break
if c == 0:
for k in range(r - 1, -1, -1):
if arr[i + k]:
area = i + k + r
i += k + 1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
x = r - 1
b = 0
for m in range(min(x, n - 1), -1, -1):
if a[m] == 1:
i = m
b = 1
break
if b == 0:
s = -1
else:
s = 1
while i + x < n - 1:
j = i + 1
b = 0
for l in range(min(j + 2 * x, n -... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR N... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | import sys
n, r = map(int, input().split())
A = list(map(int, input().split()))
count = 0
i = 0
while i < n:
for j in range(min(i + r - 1, n - 1), max(i - r, -1), -1):
if A[j] == 1:
count += 1
if j + r > i:
i = j + r
break
else:
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NU... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n):
if a[i] == 1:
if i - r + 1 < 0:
c = 0
else:
c = i - r + 1
if i + r - 1 > n - 1:
c1 = n - 1
else:
c1 = i + r - 1
for j in range(c... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
i = 0
d = 0
while True:
ki = min(n - 1, i + r - 1)
while ki >= 0 and not a[ki]:
ki -= 1
if ki < 0:
d = -1
break
a[ki] = 0
d += 1
i = ki + r
if i > n - 1:
break
if i < 0:
d = -1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | R = lambda: map(int, input().split())
n, r = R()
a = [*R()] + [0] * (r - 1)
p = q = -r
c = 0
for i in range(n + r - 1):
if a[i]:
p = i
if i - q == 2 * r - 1:
if p == q:
c = -1
break
q = p
c += 1
print(c) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = [int(i) for i in input().split()]
ans = 0
last = -1
while last < n - 1:
pos = -1
for i in range(n - 1, max(-1, last - r + 1), -1):
if a[i] == 1 and i - r <= last:
pos = i
break
if pos == -1:
print(-1)
exit()
ans += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NUMBER BIN_OP VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
poscnt = 0
locs = list()
for i in range(n):
if a[i] == 1:
poscnt += 1
locs.append(i)
if poscnt == 0:
print(-1)
else:
loc = -1
left = right = 0
while right < n:
left = right
flag = False... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASS... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
h = list(map(int, input().split()))
h2 = [0] * len(h)
f = False
aux = 0
i = 0
while i < len(h2):
f = False
for j in range(r - 1, -r, -1):
if h[max(0, min(i + j, n - 1))] == 1:
i = i + j + r
aux += 1
f = True
break
if f ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMB... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | from sys import stdin, stdout
def right_index_search(i, arr, k):
j = i
index = -1
while j < len(arr) and j < i + k:
if arr[j] == 1:
index = j
j += 1
return index
def left_index_search(i, arr, k):
j = i - 1
index = -1
while j >= 0 and j > i - k:
if arr[... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER AS... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def main():
n, r = map(int, input().split())
a = [int(e) for e in input().split()]
r -= 1
fr = 0
ans = 0
while fr < n:
i = min(fr + r, n - 1)
flag = False
while i >= max(fr - r, 0) and not flag:
if a[i] == 1:
ans += 1
fr = i + r... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR IF VAR VAR... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def add(cnt, l, r, delta):
for i in range(l, r):
cnt[i] += delta
n, r = map(int, input().split())
a = list(map(int, input().split()))
cnt = [(0) for i in range(n)]
sooca = 0
for i in range(n):
if a[i] == 1:
add(cnt, max(0, i - r + 1), min(n, i + r), 1)
for i in cnt:
if i == 0:
prin... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
result = 0
i = 0
while i < len(a):
b = True
k = i
for j in range(min(n - 1, k + r - 1), max(0, k - r + 1) - 1, -1):
if a[j] == 1:
i = j + r
result += 1
b = False
break
if b:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
room = list(map(int, input().split()))
last = -1
ans = 0
trig = True
while trig:
if last + r < n:
for i in range(last + r, max(-1, last - r + 1), -1):
if room[i] == 1:
last = i + r - 1
ans += 1
break
eli... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NUMBE... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
arr = list(map(int, input().split()))
heaters = []
counts = [0] * n
for i in range(0, n):
if arr[i] == 0:
continue
heaters.append(i)
for j in range(max(0, i - r + 1), min(n - 1, i + r - 1) + 1):
counts[j] += 1
if 0 in counts:
print(-1)
else:
ret = len... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | x, y = map(int, input().split())
a = list(map(int, input().split()))
o = 0
i = 0
while i < len(a):
r = -1
for j in range(min(i + y - 1, len(a) - 1), max(i - y + 1, 0) - 1, -1):
if a[j] == 1:
o += 1
r = j + y
break
if r == -1:
print(-1)
exit()
i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r1 = map(int, input().split())
a = list(map(int, input().split()))
right = -1
currentRight = -1
free = r1
c = 0
total = 0
finish, stop = 0, 0
idex = 0
lastIdex = -1
while idex < n and free:
free -= 1
if a[idex] == 1:
lastIdex = idex
right = idex + r1 - 1
c += 1
if right >= n -... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER IF VAR VAR NUMB... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * n
for i in range(n):
if a[i] == 1:
if i - (r - 1) < 0:
b[0] += 1
else:
b[i - (r - 1)] += 1
if i + r < n:
b[i + r] += -1
for i in range(1, n):
b[i] += b[i - 1]
if b.cou... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = [int(x) for x in input().split()]
ns = [int(x) for x in input().split()]
def fin(i):
p = need + r - 1
last = max(need - r, -1)
j = min(len(ns) - 1, p)
while j > last:
if ns[j] > 0:
return j + r
j -= 1
return -1
need = 0
ans = 0
while need < len(ns):
ans += ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR WHILE VAR VAR IF VAR VAR NUMBER RETURN BIN_OP... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
l = list(map(int, input().split()))
num = 0
boo = False
last = 0
count = 0
if r >= n:
if l.count(1) == 0:
print(-1)
else:
print(1)
exit()
for i in range(r):
if l[i] == 1:
count += 1
last = i
if count == 0:
print(-1)
exit()
num += c... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR IF FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUN... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | from sys import exit
n, r = map(int, input().split())
lst = [*map(int, input().split())]
item, last, prev, res, i = r, -1, -1, 0, 0
for i, x in enumerate(lst[:r]):
if x == 1:
last = i
if last == prev:
print(-1)
exit()
prev, i, res, item = last, last + 1, 1, r * 2 - 1
while i < n:
if item == 0:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | from sys import exit
n, r = map(int, input().split())
arr = list(map(int, input().split()))
intervals = []
for i in range(n):
if arr[i] != 1:
continue
pos = i
left = max(0, i - r + 1)
right = min(n - 1, i + r - 1)
intervals.append([left, right])
p = 0
res = 0
while p < n:
good = list(fi... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = input().split()
i = -r
n_r = n - r
n_1 = n - 1
r1 = r * 2 - 1
res = 0
while i < n_r:
for j in range(min(i + r1, n_1), max(i, -1), -1):
if a[j] == "1":
i = j
res += 1
break
else:
res = -1
i = n_r
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUM... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def count_col(inp_ar, n, r):
res = 0
last = -1
while last < n - 1:
Flag = False
for i in list(reversed(range(max(0, last - r + 2), min(n, last + r + 1)))):
if int(inp_ar[i]) == 1:
last = i + r - 1
res += 1
Flag = True
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def main():
n, r = list(map(int, input().split()))
arr = [(True if c == "1" else False) for c in input().split()]
last_heated = 0
tot = 0
last_turned = -1
while last_heated < n:
optim = last_heated + r - 1
while True:
if optim < 0:
print("-1")
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING NUMBER NUMBER VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN IF VAR V... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def solve(n, r, a):
i = k = -1
count = 0
while i < n:
if i == -1:
for j in range(min(r, n)):
if a[j] == 1:
i = j
else:
for j in range(k + 1, min(k + 2 * r, n)):
if a[j] == 1:
i = j
if i ==... | FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR RETURN NUMBER VAR NUMBER ASSIGN VAR... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
b = [0] * n
ans = 0
for i in range(n):
if b[i] == 0:
found = False
for j in range(min(n - 1, i + r - 1), max(-1, i - r), -1):
if a[j] == 1:
for k in range(min(n - 1, j + r - 1), max(-1, j - r),... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
location = list(map(int, input().split()))
heaterlist = []
for i in range(len(location)):
if location[i] == 1:
heaterlist.append(i)
heaterlist.append(10000000)
don = 0
if heaterlist[0] >= r or heaterlist[-2] < n - r:
print(-1)
don = 1
for i in range(len(heaterlist) -... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR NUMBER BIN_OP VAR VAR EXPR FUNC_C... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = [0] + list(map(int, input().split()))
l = 0
i = 1
end = 0
while i <= n:
j = i + r - 1
j = min(j, n)
while j >= end and j <= n and a[j] < 1:
j -= 1
if j > end:
l += 1
end = j
i = j + r
else:
l = -1
break
print(l) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a, ans, p1 = list(map(int, input().split())), 0, 0
while p1 < n:
flag = 0
for i in range(min(n - 1, p1 + r - 1), p1 - 1, -1):
if a[i]:
ans += 1
p1 = i + r
flag = 1
a[i] = 0
break
if flag == 0:
c = 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR B... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
arr = [int(x) for x in input().split()]
light = [(0) for x in range(n)]
heaters = 0
if max(arr) == 0 or r == 1 and min(arr) == 0:
print(-1)
else:
for i in range(n):
if arr[i] == 1:
heaters += 1
for j in range(max(0, i - r + 1), min(n, i + r)):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER FOR... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | R = lambda: map(int, input().split())
n, r = R()
a = [1] + [0] * (r - 1) + [*R()] + [0] * (r - 1)
c = p = 0
try:
while p < n:
p = next(i for i in range(p + 2 * r - 1, p, -1) if a[i])
c += 1
except:
c = -1
print(c) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER LIST FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | inf = float("inf")
n, r = map(int, input().split())
l = list(map(int, input().split()))
dp = [inf] * n
for i in range(r):
if i < n and l[i]:
dp[i] = 1
for i in range(n):
if l[i]:
for j in range(i - (r - 1) - (r - 1) - 1, i):
if j < 0:
continue
if dp[j] != ... | ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
if a[i] == 1:
b.append([max(0, i - r + 1), min(n - 1, i + r - 1)])
x = -1
k = 0
j = -1
ok = True
while x != n - 1:
i = 0
while i <= len(b) - 1 and b[i][0] <= x + 1:
i += 1
i -= 1
if i == j:... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR LIST FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER A... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | import sys
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
n, r = inpl()
a = inpl()
b = [False] * n
res = 0
for i in range(n):
if b[i]:
continue
for j in range(-r + 1, r)[::-1]:
if i + j... | IMPORT ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
l = list(map(int, input().split()))
ka = [0] * n
flag = 0
for i in range(n):
if l[i] == 1:
z1 = i - r + 2
z2 = i + r
z1 = max(1, z1)
z2 = min(n, z2)
for i in range(z1 - 1, z2):
ka[i] += 1
count = 0
for _ in range(len(ka)):
if k... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def solve(house, r):
last = -1
house[0] = -1 if house[0] == 0 else 0
for i in range(1, len(house)):
if house[i] == 1:
house[i] = i
else:
house[i] = house[i - 1]
count = 0
while last < len(house) - 1:
left = max(-1, last - r + 1)
right = last + ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER A... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | import sys
input = sys.stdin.readline
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def lcm(a, b):
return a * b / gcd(a, b)
def main():
n, r = map(int, input().split())
a = list(map(int, input().split()))
prev = -1
f = 1
ind = 0
ans = 0
while ind < n:
... | IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NU... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = tuple(map(int, input().split()))
arr = list(map(int, input().split()))
i, j = 0, 0
last_heater = -1
heaters_on = 0
while j < n:
if arr[j] == 1:
last_heater = j
if i == j - r + 1:
heaters_on += 1
if last_heater == -1:
print(-1)
exit()
i = last_heater... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = tuple(map(int, input().split()))
i = 0
c = 0
while i < n:
j = min(n - 1, i + r - 1)
while not a[j]:
j -= 1
if j < 0 or j < i - r + 1:
print(-1)
exit()
c += 1
i = j + r
print(c) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER EX... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | R = lambda: map(int, input().split())
z, r = R()
p = q = -1
a = 0
for i, x in enumerate(R()):
if x:
p = i + r - 1
if i - q == r:
if p == q:
break
q = p
a += 1
print((a, a + 1, -1)[(i > p) + (i > q)]) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER BIN_... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
list_a = list(map(int, input().split()))
count = 0
next = 0
i = 0
ans = 0
if n <= r:
if 1 in list_a:
count = 1
else:
ans = -1
else:
while True:
if i > r - 1:
ans = -1
break
elif list_a[r - 1 - i] == 1:
next ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR IF NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = [int(i) for i in input().split()]
prevT = -1
result = 0
prevH = 0
flag = 0
while prevH < n:
if flag == 0:
aux = prevH + (r - 1)
while 1:
if aux < 0 or prevT >= aux:
print(-1)
flag = 1
break
i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER WHILE NUMBER IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIG... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
sum, ans, p2, p1 = 0, 0, -1, -1
for i in range(n):
if a[i] == 1:
sum += 1
if p2 > p1:
ans += 1
p2 = i + r - 1
if i >= p1 + r:
if p2 > p1:
p1 = p2
else:
print(-1)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR VAR IF VAR... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split(" "))
array = list(map(int, input().split(" ")))
i = 0
sol = True
heaters = 0
while i < n:
found = False
maxLimit = min(n - 1, i + r - 1)
minLimit = max(i - r + 1, 0)
while maxLimit >= minLimit:
if array[maxLimit]:
found = True
break
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | import sys
n, r = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
l = 0
l1 = -1
b = [(0) for i in range(n)]
for i in range(n):
if a[i] == 0:
continue
ans += 1
f = min(n, i + r)
s = max(0, i - r + 1)
for j in range(s, f):
b[j] += 1
for i in range(n):
if b[i]... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def solve(n, r, a):
ans = 0
last = -1
while last < n - 1:
pos = -1
for i in range(n - 1, max(-1, last - r + 1), -1):
if a[i] == 1 and i - r <= last:
pos = i
break
if pos == -1:
return -1
ans += 1
last = pos + r -... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER RETURN NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER R... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
k = -1
for i in range(n):
if a[i] == 1:
if i - r > k:
ans = 0
break
tmp = 0
for j in range(i, n):
if a[j] == 1:
if j - r <= k:
tmp = j + r - 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER IF BIN_OP ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
ar = [int(i) for i in input().split()]
ans = 0
ind = -1
while ind < n - 1:
t = -10
q = ind - r + 1
q = max(q, -1)
for i in range(n - 1, q, -1):
if ar[i] and ind + r >= i:
t = i
ind = t + r - 1
ans = ans + 1
break
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMB... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
lo = 0
ans = 0
pre = -1
while lo < n:
to = min(n - 1, lo + r - 1)
while to > pre:
if a[to] == 1:
break
to -= 1
else:
ans = -1
break
lo = to + r
pre = to
ans += 1
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR NU... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = input().split()
def solve():
ret = 0
i = 0
while i < n:
for j in range(min(i + r - 1, n - 1), max(-1, i - r), -1):
if a[j] == "1":
ret += 1
i = j + r
break
else:
return -1
retur... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, h_power = list(map(int, input().strip().split()))
arr = (
[1]
+ [0] * (h_power - 1)
+ list(map(int, input().strip().split()))
+ [0] * (h_power - 1)
+ [1]
)
n = len(arr)
max_dist = 0
dist = 0
for num in arr:
if num == 0:
dist += 1
else:
dist = 0
if dist > max_dist:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER LIST NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
arr = [1] + [0] * (r - 1) + [int(i) for i in input().split()]
n = len(arr)
i, prev, ans, crutch = 0, 0, 0, False
while i < n - 1:
ans += 1
prev = i
i += 2 * r - 1
if prev + r - 1 >= n - 1:
if crutch:
print(ans - 1)
break
print(-1)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_O... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | from sys import stdin
n, m = map(int, input().split())
s = [-1] + list(map(int, stdin.readline().strip().split()))
dp = [[(10**4) for i in range(2)] for j in range(n + 1)]
dp[0][0] = 0
dp[0][1] = 0
for i in range(1, n + 1):
if s[i] == 1:
dp[i][1] = min(dp[max(i - m, 0)][0] + 1, dp[max(i - m, 0)][1] + 1)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FU... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
cur = 0
res = 0
while cur < n:
b = max(0, cur - r + 1)
c = a[b : cur + r]
if sum(c):
i = len(c) - c[-1::-1].index(1) - 1
cur = b + i + r
res += 1
else:
print(-1)
break
else:
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | import sys
def minp():
return sys.stdin.readline().strip()
n, r = map(int, minp().split())
k = r
f = None
fl = None
res = 0
i = 0
for a in map(int, minp().split()):
if i == k:
if f == None:
print(-1)
exit(0)
fl = f
k = f + 2 * r
f = None
res +=... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR IF VAR NONE EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN V... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
if r == 1:
for e in a:
if e == 0:
print(-1)
break
else:
print(n)
elif r < n:
rm1 = r - 1
ci = rm1
c = 0
lasthit = -1
flag = True
while ci < n:
if a[ci] == 1:
l... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBE... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def mainA():
T = int(input())
for i in range(T):
L, v, l, r = map(int, input().split())
ans = L // v
dow = l // v * v
up = r // v * v
if dow < l:
dow += v
ans -= max((up - dow) // v + 1, 0)
print(ans)
def mainB():
n, r = map(int, input().... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMB... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
s = [int(x) for x in input().split()]
ptr = 0
c = 1
temp = 0
lst = 0
ct = 0
ans = 0
while ptr < n:
if ptr == n - 1 and c > 0:
ptr = lst
c = r
if c == r and s[ptr] == 1:
c = -r + 2
ptr = ptr + 1
ans = ans + 1
elif c == r and s[ptr] != 1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def solve(arr):
if 1 in arr[::-1]:
return len(arr) - arr[::-1].index(1) - 1
return -1
n, r = map(int, input().split())
arr = list(map(int, input().split()))
flag = 1
curr = r
t = -1
count = 0
while True:
tt = t
t = solve(arr[t + 1 : curr]) + t + 1
if t == tt:
flag = 0
break... | FUNC_DEF IF NUMBER VAR NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUM... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, b = map(int, input().split())
arr = list(map(int, input().split()))
i = -1
j = b - 1
if j >= n:
j = n - 1
flag = 0
count = 0
while j < n:
while j > i:
if arr[j] == 1:
i = j
j += 2 * b - 1
count += 1
break
else:
j -= 1
if j - b >=... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP B... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
b = []
j = 0
for i in range(n):
if a[i] == 1:
b.append(i)
i = 0
m = len(b)
ans = 0
while i < n:
while j + 1 < m and b[j + 1] <= i + r - 1:
j = j + 1
if j < m and b[j] <= i + r - 1 and b[j] >= i - r + 1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | a, b = [int(z) for z in input().split()]
y = input().split()
h = b
q = 0
t = True
f = -1
Z = True
r = 0
for i in range(a):
if i < h:
if y[i] == "1":
if t:
q += 1
t = False
f = i
else:
if f == -1:
Z = False
break
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR STRING IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | nos = list(map(int, input().split()))
arr = list(map(int, input().split()))
i, j, minj = 0, len(arr) - 1, len(arr)
heater, lock = 0, 0
while i < len(arr) and j >= 0:
if arr[j]:
if lock == 0 and minj == j:
heater = -1
break
if abs(i - j) <= nos[1] - 1:
if lock == 0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR IF VAR NUMBER VAR VAR ASSIGN VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = input().split(" ")
heat = list(map(int, input().split(" ")))
n = int(n)
r = int(r)
if r is 1:
if 0 in heat:
ct = -1
else:
ct = n
elif r >= n:
if 1 in heat:
ct = 1
else:
ct = -1
else:
r = r - 1
ct = 0
pos = -1
posHeat = -1
while posHeat < n - 1:
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR VAR IF NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def min(a, b):
if a < b:
return a
else:
return b
def serc(x, d):
if d < 0:
return 1000000000
if x == n:
if d < r - 1:
return 1000000000
return 0
if dp[x][d] != -1:
return dp[x][d]
dp[x][d] = 1000000000
if ar[x] == 1:
dp[x]... | FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR IF VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER B... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = list(map(int, input().split()))
a = list(map(int, input().split()))
a.insert(0, 0)
pos = 1
ans = 0
last = 0
while True:
if pos > n:
break
prelast = last
for i in range(max(0, pos - r + 1), min(pos + r, n + 1)):
if a[i] == 1:
pos = i + r
last = i
if prelast ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | from itertools import accumulate
n, r = map(int, input().split())
A = list(map(int, input().split()))
imos = [0] * (n + 1)
for i in range(n):
if A[i] == 0:
continue
imos[max(0, i - r + 1)] += 1
imos[min(i + r - 1 + 1, n)] -= 1
imos = list(accumulate(imos))
for i in range(n):
if imos[i] == 0:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
li = [int(i) for i in input().split()]
res = 1
x = -1
for i in range(min(n - 1, r - 1), -1, -1):
if li[i] == 1:
x = i
break
else:
print(-1)
exit()
while x + r - 1 < n - 1:
for i in range(min(n - 1, x + 2 * r - 1), x, -1):
if li[i] == 1:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR WHILE ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
i = ans = 0
while i < n:
pointer = i
f = 0
while pointer < n:
if pointer - r + 1 > i:
break
if a[pointer] == 1:
j = pointer
f = 1
pointer += 1
if f == 0:
poi... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
i = 0
cnt = 1
flag = 1
k = 0
for i in range(min(n, r)):
if a[i] == 1:
flag = 0
k = i
i = k
if flag:
print(-1)
else:
while i + r - 1 < n - 1:
flag = 1
for j in range(i + 1, i + 2 * r):
if j < n:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR EXPR FU... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [0] * n
ans = 0
summ = 0
for i in range(n):
if a[i] == 1:
summ += 1
x = max(0, int(i - m + 1))
y = min(n - 1, int(i + m - 1))
for j in range(x, y + 1):
b[j] += 1
for i in range(n):
if a[i] ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | ab = list(map(int, input().split()))
a = ab[0]
b = ab[1]
c = list(map(int, input().split()))
s = [0] * a
idx = 0
while True:
tmp = -1
for j in range(idx - b + 1, idx + b):
if j >= 0 and j < a and c[j] == 1:
tmp = j
if tmp == -1:
print(-1)
exit()
s[tmp] = 1
idx = t... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.