#include "ricehub.h"
#define lli long long
const lli MAXN=100005;
lli pref[MAXN];
int besthub(int R, int L, int X[], long long B)
{
for(lli i=0; i<R; i++)
{
if(i==0)pref[i]=X[i];
else pref[i]=pref[i-1]+X[i];
}
lli p1=0, p2=0, p3=0, now=0, sum=0, ans=0;
for(p1=-1; p1<R; p1++)
{
if(p2<p1+1)p2=p1+1;
for(; p2<R; p2++)
{
if(p1!=-1){
now=(pref[p2]-pref[p1])/(p2-p1);
}
else{
now=pref[p2]/(p2);
}
while(p3<p2 and X[p3+1]<=now)p3++;
if(p1!=-1)sum=(pref[p1]+pref[p2]-2*pref[p3])+now*(2*p3-p1-p2);
else sum=(pref[p2]-2*pref[p3])+now*(2*p3-p2);
if(sum>B)break;
if(ans<p2-p1)ans=p2-p1;
}
p2--;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
852 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |