-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ18113.cpp
More file actions
52 lines (48 loc) · 877 Bytes
/
BOJ18113.cpp
File metadata and controls
52 lines (48 loc) · 877 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
52
/*
제길....
1. 길이 16짜리 김밥을 꼬다리 8로 자르면 김밥 길이가 0으로 계산해야 했다^^;;
-> 그냥 한 쪽만 잘라서 8로 계산해서 틀렸다...
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#define INF 2123456789
using namespace std;
int n, k, m, a;
vector<int> v;
bool test(int input) {
int cnt = 0;
for (auto a : v)
cnt += a / input;
return cnt >= m;
}
int main()
{
cin >> n >> k >> m;
while (n--) {
cin >> a;
if (a - 2 * k >= 0) {
v.push_back(a - 2 * k);
continue;
}
else if (a - k > 0) {
v.push_back(a - k);
continue;
}
}
int low = 1, high = 1000000000,ans=-1;
while (low <= high) {
int mid = (low + high) / 2;
if (test(mid)) {
ans = max(mid, ans);
low = mid + 1;
}
else
high = mid-1;
}
cout << ans;
return 0;
}