标签:bit clu code namespace can problem ret 输出 例题
#include<bits/stdc++.h>
using namespace std;
int n,m,L,R,ans;
long long s[100005],a[100005],Max;
bool check(){
long long last=0;
for(int i=m;i<=n;i++){
if(s[i]-last>=0) return true;
last=min(last,s[i-m+1]);
}
return false;
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
a[i]*=1000;
Max=max(a[i],Max);
}
L=0,R=Max;
long long mid;
while(L<=R){
mid=(L+R)/2;
for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i]-mid;
if(check()) L=mid+1;
else R=mid-1;
}
cout<<R;
return 0;
}
标签:bit clu code namespace can problem ret 输出 例题
原文地址:https://www.cnblogs.com/fashpoint/p/11330464.html