-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1654.cpp
More file actions
38 lines (34 loc) · 671 Bytes
/
1654.cpp
File metadata and controls
38 lines (34 loc) · 671 Bytes
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
38
#include <iostream>
#include <vector>
#include <algorithm>
#define io ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main()
{
io;
int K,N;
cin>>K>>N;
long long max=0,min=1,cen=0;
int res=0;
vector<int> lan(K);
for(int i=0;i<K;i++){
cin>>lan[i];
if(max<lan[i]) max=lan[i];
}
while(min<=max){
cen=(max+min)/2;
int count=0;
for(int i=0;i<K;i++){
count+=lan[i]/cen;
}
if(count>=N){
min=cen+1;
if(res < cen) res = cen;
}
else if(count<N) {
max=cen-1;
}
}
cout<<res;
return 0;
}