We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3ba5179 commit 460222fCopy full SHA for 460222f
프로그래머스/2/42885. 구명보트/README.md
@@ -4,7 +4,7 @@
4
5
### 성능 요약
6
7
-메모리: 10.5 MB, 시간: 9.82 ms
+메모리: 58.4 MB, 시간: 12.13 ms
8
9
### 구분
10
@@ -16,7 +16,7 @@
16
17
### 제출 일자
18
19
-2024년 2월 2일 0:26:42
+2025년 06월 04일 02:22:47
20
21
### 문제 설명
22
프로그래머스/2/42885. 구명보트/구명보트.java
@@ -0,0 +1,24 @@
1
+import java.util.*;
2
+
3
+class Solution {
+ public int solution(int[] people, int limit) {
+ int rideTogether = 0;
+ Arrays.sort(people);
+ int left = 0;
+ int right = people.length - 1;
11
12
+ while(left < right){
13
+ if(people[left] + people[right] <= limit){ // 둘이 타기에 충분한 경우
14
+ left++;
15
+ right--;
+ rideTogether++;
+ }else{ // 한명밖에 못타는 경우 -> 무게가 더 많이 나가는 사람을 대체
+ }
+ return people.length - rideTogether;
23
24
+}
0 commit comments