C++编写,前面的都通过了,只剩下Subtask#1那一个测试点没过,希望各位大佬告诉我哪里该改一下以下是代码:
#include<bits/stdc++.h>
using namespace std;
int m,n,a[1000010],cd,l=1,r;
int main(){
int d,e=0;
cin>>cd>>n>>m;
for(int i=0;i<n;i++){
cin>>d;
a[i]=d-e;
e=d;
}
a[n]=cd-e;
l=1;
if(n==m){
cout<<cd;
return 0;
}
r=cd/(n-m);
while(l<=r){
int mid=(l+r)/2,f,count=0;
for(int i=0;i<=n;i++){
f=a[i];
while((f<mid)&&(i<n)){
i++;
f+=a[i];
count++;
}
}
if(count<=m){
l=mid+1;
}
else{
r=mid-1;
}
}
cout<<r;
}