Answer the question
In order to leave comments, you need to log in
Python. What does this line do?
Tell me, please, what does line three (Buf = [0]*K) mean in this program.
N = int(input())
K = 7
Buf = [0]*K
for i in range(N):
elem = int(input())
next = Buf[i % K]
Buf[i % K] = elem
if i == K:
maxPrev = next
maxSum = next + elem
if i > K:
maxPrev = max(maxPrev, next)
maxSum = max(maxSum, maxPrev+elem)
Answer the question
In order to leave comments, you need to log in
Buf = [0]*K
is equivalent to the following construction:
I.e. Buf is a list, each element of which is 0.
list multiplication. Sit in a shell and practice....
>>> dd = [0] * 7
>>> dd
[0, 0, 0, 0, 0, 0, 0]
>>>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question