It is limited, at the problem is not the solution, a lot of understanding
Thank you for watching this konjac
Topic: https://www.luogu.org/problem/P3853
Because data n <= 10000000; can be derived by analyzing a sample which is one to two sub-themes.
Sample Analysis: The interval period is divided into (k + n) segments, identify (k + n) of the maximum section. Because k uncertain, so not sure how the points, we are to find out the maximum value of this compared with the rest of the period throughout several cases, these take the smallest inside .
This question is one half of the answer to the question of the template, you can just pay attention to details
code:
#include<bits/stdc++.h> //#pragma GCC optimize(3) int l,n,k,a[110000],dis[110000],ans=0,kk,mm,yzl; using namespace std; inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch<=' . 9 ' && CH> = ' 0 ' ) {X = (X << . 1 ) + (X << . 3 ) + (CH ^ 48 ); CH = getchar ();} return X * F; } BOOL Check ( int MID) // determines whether to continue bipartite go { int NUM = 0 ; for ( int I = . 1 ; I <n-; I ++ ) { NUM + = DIS [I] / MID; // since this problem is always a straight line that is: 0 ~ len mid half continue, eventually several statistical 1/2 } IF (NUM> K)return 0 ; return . 1 ; } int main () { int LS, MID, RS; L = Read (), n-= Read (), K = Read (); for ( int I = . 1 ; I <= n-; I ++ ) a [I] = Read (); for ( int I = . 1 ; I <n-; I ++ ) { DIS [I] = a [I + . 1 ] -a [I] - . 1 ; // must be decremented, since the this problem is a spacer, which ensures the start point and the end point are provided signs // need only be evenly distributed intermediate portion } LS = 0; RS = L; the while (LS <= RS) { MID = LS + RS >> . 1 ; IF (Check (MID)) { RS = mid- . 1 ; YZL = MID; } the else { LS = MID + . 1 ; } } the printf ( " % D \ n- " , YZL); // At this mid == ls, may be directly output LS return 0 ; } / * . 9 2 2 0. 8 . 3 * /