Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- using namespace std;
- bool check(int a,vector<int>v,int k)
- {
- int last=v[0]+a;
- k--;
- for( int i=1;i<v.size();i++)
- {
- if(abs(v[i]-last)>a)
- {
- if(k==0) return 0;
- last=v[i]+a;
- k--;
- }
- }
- return 1;
- }
- int main()
- {
- optimize();
- int t;
- cin>>t;
- for(int tc=1;tc<=t;tc++)
- {
- int n,m,k;
- cin>>n>>m>>k;
- vector<int>v(m);
- for(int i=0;i<m;i++) cin>>v[i];
- int l=0,r=n,ans;
- while(l<=r)
- {
- int mid=(l+r)/2;
- if(check(mid,v,k))
- {
- ans=mid;
- r=mid-1;
- }
- else l=mid+1;
- }
- cout<<"Case "<<tc<<": "<<ans<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement