forked from encrypted-def/basic-algo-lecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16401.cpp
More file actions
41 lines (34 loc) · 745 Bytes
/
16401.cpp
File metadata and controls
41 lines (34 loc) · 745 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
// Authored by : unluckyjung
// Co-authored by : BaaaaaaaaaaarkingDog
// http://boj.kr/64af97a2770445c3a53daa9403c1cf46
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int m, n;
int l[1000002];
// 막대 과자의 길이가 x일 경우 m조각 이상이 나오는가?
bool solve(int x) {
if (x == 0) return true;
ll cnt = 0;
for (int i = 0; i < n; ++i) {
cnt += l[i] / x;
}
return cnt >= m;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> m >> n;
for (int i = 0; i < n; ++i)
cin >> l[i];
int st = 0;
int en = *max_element(l, l+n);
while (st < en) {
int mid = (st + en + 1) / 2;
if (solve(mid))
st = mid;
else
en = mid - 1;
}
cout << st << "\n";
}