티스토리 뷰
programmers.co.kr/learn/courses/30/lessons/42885
from collections import deque
def solution(people, limit):
answer = 0
people.sort()
people = deque(people)
while(people):
if len(people) == 1:
people.pop()
else:
heavy = people.pop()
light = people.popleft()
if (heavy + light) > limit:
people.appendleft(light)
answer += 1
return answer
'Algorithm > Programmers' 카테고리의 다른 글
[프로그래머스] 기능개발 - Python (0) | 2021.03.26 |
---|---|
[프로그래머스] 튜플 - Python (0) | 2021.03.25 |
[프로그래머스] 다리를 지나는 트럭 - Python (0) | 2021.03.25 |
[프로그래머스] 주식가격 - Python (0) | 2021.03.25 |
[프로그래머스] 프린터 - Python (0) | 2021.03.25 |