다리를 지나는 트럭 (1) 썸네일형 리스트형 [ 프로그래머스 ] 다리를 지나는 트럭 / 코드 1 / def solution(bridge_length, weight, truck_weights): q=[0]*bridge_length sec=0 while q: sec+=1 q.pop(0) if truck_weights: if sum(q)+truck_weights[0] weight: bridge.append(0) else: truck = truck_weights.pop() bridge.append(truck) total_weight += truck step += 1 step += bridge_length return step 이전 1 다음