from collections import deque
def solution(people, limit):
answer = 0
people.sort()
people = deque(people)
while people:
max_weight = people.pop()
if people and max_weight + people[0]<=limit:
people.popleft()
answer +=1
return answer
'Programming > Programmers' 카테고리의 다른 글
[프로그래머스/Python] 문자열 압축(중복체크/반복문) (0) | 2021.01.05 |
---|---|
[프로그래머스/Python] 짝지어 제거하기(스택) (0) | 2021.01.04 |
[프로그래머스/Python] 소수찾기(완전탐색) (0) | 2021.01.03 |
[프로그래머스/Python] 괄호변환(재귀/구현) (0) | 2021.01.03 |
[프로그래머스/Python] 기능개발(큐) (0) | 2021.01.03 |