//Rochy
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define fl(i,a,b) for(int i=a;i<b;++i)
#define fa(i,a) for(auto (i):(a))
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define vi vector <int>
#define ii pair <int,int>
#define pb push_back
using namespace std;
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));
if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar()))x=x*10+c-48;if(nega)x=-x;}
template <typename T> inline void writep(T x){if(x>9)writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
template <typename R, typename D> inline void Min(R &a, D b){if(a>b) a=b;}
template <typename D, typename R> inline void Max(D &a, R b){if(a<b) a=b;}
const int N=100005,M=300005;
int n,lim,sum[N];
long long cost;
bool check(int x){
int run=(x+1)/2;
int l=1;
int r=x;
long long cur=0;
fl(i,1,run) cur+=sum[run]-sum[i];
fo(i,run+1,x) cur+=sum[i]-sum[run];
for(;r<=n;){
if(cur<=cost) return 1;
cur-=sum[l+1]-sum[l];
cur+=sum[r+1]-sum[r];
++l,++r;
}
return 0;
}
int main(){
ios_base::sync_with_stdio(NULL);
cin. tie(NULL); cout. tie(NULL);
#ifndef ONLINE_JUDGE
// freopen(".inp" , "r", stdin);
#endif
cin>>n>>lim;
fo(i,1,n){
cin>>sum[i];
}
cin>>cost;
int r=n+1;int l=1;
while(r-l>1){
int mid=(l+r)>>1;
if(check(mid)) l=mid;
else r=mid;
}
cout<<l;
return 0;
}
Compilation message
/tmp/ccRbOet1.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccsrMLYJ.o:ricehub.cpp:(.text.startup+0x0): first defined here
/tmp/ccRbOet1.o: In function `main':
grader.cpp:(.text.startup+0x92): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status