반응형

문제 설명

https://www.acmicpc.net/problem/1817

 
 
 
 

 

 

제출한 코드

n, m = map(int, input().split())
book = 0
box = 0
if n != 0 :
    lst = list(map(int, input().split()))
    box += 1
    for i in range(n) :
        book += lst[i]
        if book > m :
            book = lst[i]
            box += 1
print(box)

 

 

 

 

결과

 

 

 

후기

예제를 보면 알 수 있겠지만, 책을 정리해서 넣는 게 아니라 입력한 순서대로 넣는 것이다. 지문 수정 요청은 이미 있길래 따로 넣지는 않았다.

 

 

 

 

 

 

 

반응형

+ Recent posts