File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed
Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 58.4 MB, 시간: 17.38 ms
7+ 메모리: 57.6 MB, 시간: 11.06 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2025년 09월 05일 18:27:34
19+ 2025년 09월 09일 22:46:20
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 22
33class Solution {
44 public int solution (int [] people , int limit ) {
5- ArrayList <Integer > list = new ArrayList <>();
65 Arrays .sort (people );
7-
8- int light = 0 ;
9- int heavy = people .length -1 ;
106
7+ int light = 0 ;
8+ int heavy = people .length - 1 ;
9+ int cnt = 0 ;
1110 while (light <= heavy ){
12- if (people [light ] + people [heavy ] > limit ){
13- list .add (people [heavy ]);
14- heavy --;
15- } else {
16- list .add (people [heavy ] + people [light ]);
17- heavy --;
11+
12+ // 둘이 탈 수 있음
13+ if (people [heavy ] + people [light ] <= limit ){
14+ cnt ++;
15+ heavy --;
1816 light ++;
17+ } else { // 혼자만 탐
18+ cnt ++;
19+ heavy --;
1920 }
2021 }
21- return list . size () ;
22+ return cnt ;
2223 }
2324}
You can’t perform that action at this time.
0 commit comments