

import sys
n, m = map(int, sys.stdin.readline().split())
numbers = list(map(int, sys.stdin.readline().split()))
left = 0
right = 1
temp = 0
answer = 0
while left <= right:
if right > len(numbers):
break
temp = sum(numbers[left:right])
if temp < m:
right += 1
elif temp > m:
left += 1
elif temp == m:
answer += 1
left += 1
print(answer)'Algorithm > BOJ' 카테고리의 다른 글
| [BOJ] 11724. 연결 요소의 개수 Python 풀이 (0) | 2023.04.14 |
|---|---|
| [BOJ] 1012. 유기농 배추 Python 풀이 (0) | 2023.04.05 |
| [BOJ] 1158. 요세푸스 문제 Python 풀이 (0) | 2023.02.17 |
| [BOJ] 9012. 괄호 Python 풀이 (0) | 2023.01.05 |
| [BOJ] 10814. 나이순 정렬 Python 풀이 (0) | 2023.01.04 |