탐욕법 프로그래머스 문제
구명보트
from collections import deque def solution(people, limit): answer = 0 people.sort(key= lambda x : -x) p = deque(people) while p: if len(p) > 1 and p[0] + p[-1] <= limit: p.pop() p.popleft() answer += 1 return answer