这题我认为python选手最好要用deque来模拟,不断popleft直到deque空了就行了。
from sys import stdin
from collections import deque
input = stdin.readline
n,v = map(int,input().split())
l = deque(map(int,input().split()))
cnt = 0
while l:
tempv = v
while l:
if l[0] <= tempv:
tempv -= l.popleft()
else:
break
cnt += 1
print(cnt)