-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj1477
More file actions
45 lines (41 loc) · 685 Bytes
/
Copy pathboj1477
File metadata and controls
45 lines (41 loc) · 685 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
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m,l;
vector<int> v;
bool chk(int mid){
int cnt = 0;
for(int i=1; i<v.size(); i++){
int dist = v[i] - v[i-1];
cnt += dist / mid;
if(dist % mid == 0){
cnt--;
}
}
return cnt > m;
}
int main(void){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> l;
v.push_back(0);
v.push_back(l);
for(int i=0; i<n; i++){
int x; cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
int st = 1, en = l;
int mid,ret=0;
while(st <= en){
mid = (st + en) / 2;
if(chk(mid)){
st = mid + 1;
}else{
ret = mid;
en = mid - 1;
}
}
cout << ret;
return