#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
//#define unx 1
#ifndef unx
#include "ricehub.h"
#endif // unx
long long s[100010];
int besthub(int r,int l,int x[],long long b){
int best=0;
//vector<long long> s(r+1);
forinc(i,1,r) s[i]=s[i-1]+x[i-1];
int le,mi,ri,ret;
forinc(i,1,r){
le=0,ri=min(i-1,r-i),ret=-1;
while(le<=ri){
mi=(le+ri)/2;
if(s[i+mi]-s[i]-s[i-1]+s[i-mi-1]<=b) ret=mi,le=mi+1;
else ri=mi-1;
}
best=max(best,ret+ret+1);
le=0,ri=min(i-1,r-i),ret=-1;
while(le<=ri){
mi=(le+ri)/2;
if(s[i+mi+1]-s[i]-s[i-1]+s[i-mi-1]-x[i-1]<=b) ret=mi,le=mi+1;
else ri=mi-1;
}
best=max(best,ret+ret+2);
}
return best;
}
#ifdef unx
int a[100010];
main(){
#define task "rice"
//freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
int r,l; long long b;
cin>>r>>l>>b;
forinc(i,1,r) cin>>a[i-1];
cout<<besthub(r,l,a,b);
cerr<<besthub(r,l,a,b);
}
#endif // unx
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |