https://www.acmicpc.net/problem/13335
13335번: 트럭
입력 데이터는 표준입력을 사용한다. 입력은 두 줄로 이루어진다. 입력의 첫 번째 줄에는 세 개의 정수 n (1 ≤ n ≤ 1,000) , w (1 ≤ w ≤ 100) and L (10 ≤ L ≤ 1,000)이 주어지는데, n은 다리를 건너는 트
www.acmicpc.net
from collections import deque
def solution():
time = 0
while len(data)!=0 or sum(a)!=0:
a[0] = 0
a.rotate(-1)
if len(data)!=0 and (sum(a) + data[0]) <= l:
number = data.pop(0)
a[w - 1] = number
time += 1
return time
n,w,l = map(int,input().split())
data = list(map(int,input().split()))
a = deque([0]*w)
print(solution())
'알고리즘' 카테고리의 다른 글
programmers 타겟 넘버(Python) (0) | 2021.06.06 |
---|---|
programmers 키패드 누르기(Python) (0) | 2021.06.06 |
백준16918번 : 봄버맨(Python) (0) | 2021.03.31 |
백준20061 : 모노미노도미노2(Python) (0) | 2021.03.11 |
백준 1158번 : 요세푸스 문제 (Python) (0) | 2021.02.03 |