-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_1654.java
37 lines (29 loc) · 954 Bytes
/
number_1654.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.Arrays;
import java.util.Scanner;
public class number_1654 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); //가지고 있는 랜선 개수
int need_n = sc.nextInt(); //필요한 랜선 개수
int lancable_arr[] = new int[n];
for(int i=0;i<n;i++){
lancable_arr[i] = sc.nextInt();
}sc.close();
long start=1;
long end=Arrays.stream(lancable_arr).max().getAsInt();
while(start<=end){
long mid = (start + end)/2;
long possible = 0;
for(int i=0;i<lancable_arr.length;i++){
possible += lancable_arr[i]/mid;
}
if(possible >= need_n){
start = mid + 1;
}
else{
end = mid - 1;
}
}
System.out.println(end);
}
}