bool check(int mid){
int sum=0,sumL=0;
for(int i=1;i<=L;i++) sum += a[i] = mid;
int MaxSum = -inf ,MinSum=inf;
for(int i=L;i<=n;i++){
MaxSum = max(MaxSum,sum-MinSum);
sum += a[i+1]-mid;
MinSum = min(MinSum,sumL);
}
return MaxSum >= 0;
}
2023-10-08 23:10:46
bool check(int mid){
int sum=0,sumL=0;
for(int i=1;i<=L;i++) sum += a[i] = mid;
int MaxSum = -inf ,MinSum=inf;
for(int i=L;i<=n;i++){
MaxSum = max(MaxSum,sum-MinSum);
sum += a[i+1]-mid;
MinSum = min(MinSum,sumL);
}
return MaxSum >= 0;
}