# 題目
zerojudge c575. APCS 2017-0304-4 基地台
# 解題思路
目前沒東西...
# 程式碼
#include<bits/stdc++.h> | |
using namespace std; | |
set<int> s; | |
int n,k; | |
bool check(int tk){ | |
int b=*s.begin(); | |
for(int i=0;i<k;i++){ | |
b+=tk; | |
auto it=s.upper_bound(b); | |
if(it==s.end()) | |
return 1; | |
b=*it; | |
} | |
return 0; | |
} | |
int main(){ | |
cin>>n>>k; | |
for(int i=0,temp;i<n;i++){ | |
cin>>temp; | |
s.insert(temp); | |
} | |
int t=0; | |
for(int jump=*s.rbegin()-*s.begin();jump>0;jump>>=1){ | |
while(check(t+jump)==0) | |
t+=jump; | |
} | |
cout<<t+1; | |
} |