Submission #1251878

#TimeUsernameProblemLanguageResultExecution timeMemory
1251878cheetahWatching (JOI13_watching)C++20
0 / 100
1 ms328 KiB
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <cstdint> //#include <bits/stdc++.h> #define int long long using namespace std; const int N=1e9+7; int n,k,b; bool chick(int w,vector<int>&point){ int i=0; bool f=1; int kk=k,bk=b,onceb=0,oncek=0;//indexleri while(i<n){ if(bk>0){ int end=point[i]+2*w-1; while(i<n && point[i]<=end)i++; bk--; } else if(kk>0){ int end=point[i]+w-1; while(i<n && point[i]<=end)i++; kk--; } else{ f=0; break; } } if(f)return 1; kk=k,bk=b,i=0; while(i<n){ if(kk>0){ int end=point[i]+w-1; while(i<n && point[i]<=end)i++; kk--; } else if(bk>0){ int end=point[i]+2*w-1; while(i<n && point[i]<=end)i++; bk--; } else{ f=0; break; } } if(f)return 1; else return 0; } int32_t main(){ int ans; cin>>n>>k>>b; vector<int>point(n); for(int i=0;i<n;i++)cin>>point[i]; int l=1,r=N; sort(point.begin(),point.end()); while(l<r){ int mid=(l+r)>>1; if(chick(mid,point)){ ans=mid; r=mid; } else{ l=mid+1; } } cout<<l<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...