Skip to content

Commit 62d7dfc

Browse files
committed
[PGS] 구명보트 / 30분 / 성공
1 parent 05bd6ae commit 62d7dfc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
def solution(people, limit):
2+
answer = 0
3+
4+
people.sort()
5+
6+
left = 0
7+
right = len(people)-1
8+
9+
while left <= right:
10+
if people[left] + people[right] <= limit:
11+
left += 1
12+
right -= 1
13+
else:
14+
right -= 1
15+
16+
answer += 1
17+
18+
return answer

0 commit comments

Comments
 (0)