ji-0630 / CodingTest

코딩테스트 연습 기록
0 stars 0 forks source link

구명보트 #255

Closed ji-0630 closed 1 year ago

ji-0630 commented 1 year ago

문제 설명

image

ji-0630 commented 1 year ago

나의 풀이

def solution(people, limit):
    people = sorted(people)
    answer = 0
    s = 0
    l = len(people)-1

    while s <= l:
        if people[l] + people[s] <= limit:
            answer += 1
            s += 1
            l -= 1
        else:
            answer += 1
            l -= 1

    return answer