class Solution(object):
def numRescueBoats(self, people, limit):
"""
:type people: List[int]
:type limit: int
:rtype: int
"""
if people is None or len(people) == 0:
return 0
i = 0
j = len(people) - 1
res = 0
# 先排序很重要
people.sort()
while i <= j:
if people[i] + people[j] <= limit:
i += 1
j -= 1
res += 1
return res