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 53 54 55 56 57 58 59 60 61
|
#include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #define rep(i,l,r) for(int i=l;i<=r;++i) #define per(i,l,r) for(int i=l;i>=r;--i) using namespace std; inline int () { char c; bool t=0; int a=0; while((c=getchar())==' '||c=='n'||c=='r'); if(c=='-') { t=1;c=getchar(); } while(c>='0'&&c<='9') { a*=10;a+=(c-'0');c=getchar(); } return a*(t?-1:1); } int l,n,k,pos[100001],t_pos[100001]; bool judge(int maxx) { memcpy(t_pos,pos,sizeof pos); int temp=0; rep(i,2,n) { while(t_pos[i]-t_pos[i-1]>maxx) { ++temp; t_pos[i-1]+=maxx; } if(temp>k) return 0; } return 1; } int main() { l=read();n=read();k=read(); rep(i,1,n) pos[i]=read(); int ll=1,rr=l,mid,ans; while(ll<=rr) { mid=ll+((rr-ll)>>1); if(judge(mid)) { ans=mid; rr=mid-1; } else ll=mid+1; } cout<<ans; return 0; }
|
近期评论