Recent Posts
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Today
Total
관리 메뉴

Try

[Programmers/Python3] 다리를 지나는 트럭 본문

Algorithm/Programmers

[Programmers/Python3] 다리를 지나는 트럭

HAS3ONG 2019. 3. 8. 20:12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def solution(bridge_length, weight, truck):
    answer = 0
    queue = [0* bridge_length
    seconds = 0
    while queue:
        seconds += 1
        queue.pop(0)
        if truck:
            if sum(queue) + truck[0<= weight:
                queue.append(truck.pop(0))
            else:
                queue.append(0)
                
    answer = seconds
    return answer
cs



출처

https://programmers.co.kr/learn/courses/30/lessons/42583?language=python3

'Algorithm > Programmers' 카테고리의 다른 글

[Programmers/Python] 예산  (0) 2019.03.21
[Programmers/C++] 예산  (0) 2019.03.21
[Programmers/Python3] 주식가격  (0) 2019.03.08
[Programmers/C++] 2016년  (0) 2018.11.18
[Programmers/C++] 완주하지 못한 선수  (0) 2018.11.18
Comments