-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (36 loc) · 830 Bytes
/
Copy pathmain.cpp
File metadata and controls
36 lines (36 loc) · 830 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
#include <iostream>
#include <vector>
using namespace std;
int k, n;
long long result;
bool check(const vector<long long> &list, long long length) {
int ret = 0;
for(long long a : list) {
ret += a/length;
}
return ret >= n;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(); cout.tie();
cin >> k >> n;
vector<long long> list(k);
long long max = 0;
for(int i=0; i<k; i++){
cin >> list[i];
if(max < list[i]) max = list[i];
}
long long left = 1;
long long right = max;
while(left <= right) {
long long mid = (left + right) / 2;
if(check(list, mid)) {
if(result < mid) result = mid;
left = mid + 1;
} else {
right = mid - 1;
}
}
cout << result << '\n';
return 0;
}