Skip to content

Commit 08fe7bc

Browse files
authored
[20251024] PGM / LV3 / 입국심사 / 강신지
1 parent b5f08c0 commit 08fe7bc

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
```java
2+
import java.util.*;
3+
4+
class Solution {
5+
public long solution(int n, int[] times) {
6+
Arrays.sort(times);
7+
long min = 1;
8+
9+
long max = (long) times[times.length-1]*n;
10+
long mid = 0;
11+
long sum;
12+
long answer = max;
13+
14+
while(min <= max) {
15+
sum = 0;
16+
mid = (min + max) / 2;
17+
18+
for(int time : times) {
19+
sum += mid / time;
20+
}
21+
22+
if(sum >= n) {
23+
answer = mid;
24+
max = mid - 1;
25+
}
26+
else {
27+
min = mid + 1;
28+
}
29+
}
30+
```
31+
return answer;
32+
}
33+
}

0 commit comments

Comments
 (0)