728x90
320x100
def solution(people, limit):
answer = 1
people.sort()
weigth = 0
for i in people:
if limit < weigth + i:
answer += 1
weigth = i
else :
weigth += i
return answer
일케 짰는데 테스트 통과하고 정확성 22퍼센트대로 ㅋㅋㅋㅋㅋㅋㅋ거의 틀린거나 다름 없이 됨.
다른 분 풀이를 가지고 왔다........
def solution(people, limit):
people.sort()
start, end = 0, len(people)-1
count = 0
while start <= end:
count += 1
if (people[start] + people[end] <= limit):
start += 1
end -= 1
else:
end -= 1
return count
728x90
320x100
'💻 하나씩 차곡차곡 > 프로그래머스 (Python)' 카테고리의 다른 글
[프로그래머스/Lv.1/Pyhton] K번째수 (0) | 2024.01.24 |
---|---|
[프로그래머스/Lv2/Python] 큰 수 만들기 (0) | 2024.01.23 |
[프로그래머스/Python] [PCCP 모의고사 #1] 1번 - 외톨이 알파벳 (0) | 2024.01.18 |
[프로그래머스/LV.1/Python] 체육복 (0) | 2024.01.17 |
[프로그래머스/Lv.2/Python] 올바른 괄호 (0) | 2024.01.16 |