# 구명보트 - 프로그래머스
def solution(people, limit):
people.sort()
ret, i, end = 0, 0, len(people) - 1
while i <= end:
if people[i] + people[end] > limit:
end -= 1
else:
i += 1
end -= 1
ret += 1
return ret