https://programmers.co.kr/learn/courses/30/lessons/42583
sum을썼었는데따로가볍게계산하게끔했음
def solution(bridge_length, weight, truck_weights):
bridge=[]
for i in range(bridge_length):
bridge.append(0)
w=0
answer = 0
bridge_weight=0
while(truck_weights):
answer+=1
w-=bridge.pop()
bridge= [0]+bridge
if w+truck_weights[0] <= weight:
bridge[0]=truck_weights.pop(0)
w+=bridge[0]
return answer+bridge_length
'공부 > 코딩테스트' 카테고리의 다른 글
[알고리즘] DFS, BFS (0) | 2022.06.05 |
---|---|
[프로그래머스] 숫자의 표현(파이썬) (0) | 2022.03.21 |
[프로그래머스] 프린터(파이썬) (0) | 2022.02.16 |
[프로그래머스] 기능개발(파이썬) (0) | 2022.02.16 |
[프로그래머스] 완주하지 못한 선수(파이썬) (0) | 2022.02.16 |