-->https://programmers.co.kr/learn/courses/30/lessons/42583
다리를 지나는 트럭들을 queue에 시간과 함께 넣어 표현하였습니다.
다리에 트럭들이 들어갈 때 truck_weights에 해당 트럭을 pop하였습니다.
from collections import deque
def solution(bridge_length, weight, truck_weights):
time = 1
queue = deque()
queue.append([truck_weights.pop(0),time])
while queue:
time +=1
trucks_in_bridge=0
if time - queue[0][1] == bridge_length:
queue.popleft()
if truck_weights:
for i in queue:
trucks_in_bridge += i[0]
if trucks_in_bridge + truck_weights[0] <= weight:
queue.append([truck_weights.pop(0),time])
return time