반응형
import sys
N, M = map(int,sys.stdin.readline().split())
A = list(map(int,sys.stdin.readline().split()))
num = 0
idx = 0
q = []
while(idx <= N):
if not q or sum(q) < M:
if idx >= N:
break
q.append(A[idx])
idx += 1
elif sum(q) >= M:
if sum(q) == M:
num += 1
q.pop(0)
print(num)
반응형