문제
https://www.acmicpc.net/problem/1806
코드
n,s=map(int, input().split())
array=list(map(int, input().split()))
end=0
comp=array[0]
count=float('inf')
for i in range(n):
while comp<s and end<n:
end+=1
if end == n:
break
comp+=array[end]
if comp>=s:
count=min(count, end-i+1)
comp-=array[i]
if count == float('inf'):
print(0)
else:
print(count)
'문제풀이 > 기타' 카테고리의 다른 글
* [파이썬] [해시] Pro 위장 (0) | 2022.02.10 |
---|---|
[파이썬] [해시] Pro 전화번호 목록 (0) | 2022.02.10 |
[파이썬] [해시] Pro 완주하지 못한 선수 (0) | 2022.02.10 |
[파이썬] [기타] 우선순위 큐, 힙 (0) | 2022.02.09 |
[파이썬] [기타] 에라토스, Two Pointers, 구간합 (0) | 2022.02.08 |