Baekjoon #1817

Baekjoon #1817

1개의 풀이 · Python

문제 원문 보기 ↗

SOLUTION INFO

Python · main.py

main.py
import sys
from collections import deque

def input():
    return sys.stdin.readline().rstrip()

N, M = map(int, input().split())
ans = 0
if N == 0:
    print(ans)
else:
    queue = deque(list(map(int, input().split())))
    while queue:
        weight = 0
        while queue and weight + queue[0] <= M:
            weight += queue.popleft()
        ans += 1
    print(ans)

SOLUTION DESCRIPTION

풀이 설명

등록된 풀이 설명이 없습니다.