-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbee2329.cpp
More file actions
51 lines (35 loc) · 737 Bytes
/
Copy pathbee2329.cpp
File metadata and controls
51 lines (35 loc) · 737 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
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Contest : Beecrowd
* Problem : 2329 - Pão a Metro
* Link : https://judge.beecrowd.com/pt/problems/view/2329
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int n, k, x;
int v[112345];
int f(int x) {
int cnt = 0;
for (int i = 0; i < n; i++) { cnt += v[i] / x; }
return cnt;
}
int bs(int x) {
int l = 0, r = *max_element(v, v + n), ans = -1, m;
while (l <= r) {
m = l + (r - l) / 2;
if (f(m) >= k) {
ans = m;
l = m + 1;
} else
r = m - 1;
}
return ans;
}
int main() {
fastio
scanf("%i %i", &k, &n);
for (int i = 0; i < n; i++) scanf("%i", &v[i]);
printf("%i\n", bs(n));
return 0;
}