83742024-01-15 10:40:19birozsVirágos rét (50 pont)python3Accepted 50/50126ms23024 KiB
#be = open("be3.txt")
#n,k = map(int,be.readline().split())
#lista = list(map(int,be.readline().split()))

n,k = map(int,input().split())
lista = list(map(int,input().split()))
if lista[0] == 0:
    db = [0]
else:
    db = [1]
for i in range(1,n):
    if lista[i] == 1:
        db.append(db[i-1]+1)
    else:
        db.append(db[i-1])
if db[-1] < k:
    print(0)
else:
    ut = 0
    i = n-1
    while db[i] >= k:
        if lista[i] == 1:
            ut += db[i] - k + 1
        i -= 1
    print(ut)
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/018ms11624 KiB
2Accepted0/017ms11880 KiB
3Accepted0/086ms16172 KiB
4Accepted2/217ms12352 KiB
5Accepted2/217ms12456 KiB
6Accepted2/217ms12632 KiB
7Accepted3/317ms12824 KiB
8Accepted3/317ms12844 KiB
9Accepted3/317ms13228 KiB
10Accepted2/217ms13252 KiB
11Accepted3/318ms13120 KiB
12Accepted2/219ms13592 KiB
13Accepted3/318ms13720 KiB
14Accepted2/268ms22960 KiB
15Accepted2/2123ms22672 KiB
16Accepted3/3104ms19992 KiB
17Accepted3/382ms18152 KiB
18Accepted3/3119ms21092 KiB
19Accepted3/393ms17552 KiB
20Accepted3/379ms22396 KiB
21Accepted3/3104ms19252 KiB
22Accepted3/3126ms23024 KiB