20250723 baekjoon
This commit is contained in:
parent
fdcf787662
commit
841d32138f
36
code_study/Baekjoon/c/1654.c
Normal file
36
code_study/Baekjoon/c/1654.c
Normal file
@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(){
|
||||
int K, N;
|
||||
scanf("%d %d",&K, &N);
|
||||
int* cable = (int*)malloc(sizeof(int)*K);
|
||||
scanf("%d",&cable[0]);
|
||||
long long start = 1;
|
||||
long long end = cable[0];
|
||||
for(int i=1; i<K; i++){
|
||||
scanf("%d",&cable[i]);
|
||||
if(cable[i]>end) end = cable[i];
|
||||
}
|
||||
|
||||
long long result;
|
||||
while(start<=end){
|
||||
int count = 0;
|
||||
long long mid = (long long)(start + end)/2;
|
||||
for(int i=0; i<K; i++){
|
||||
count += cable[i]/mid;
|
||||
}
|
||||
|
||||
if(count < N) {
|
||||
end = mid - 1;
|
||||
}
|
||||
else if(count >= N) {
|
||||
result = mid;
|
||||
start = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%lld\n",result);
|
||||
free(cable);
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user