#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long ma=-1;
int besthub(int R, int L, int X[], long long B){
/* if(R<=500){ ma=-1;
for(int i=0;i<R;i++){
for(int j=i;j<R;j++){
// cout<<i<<" "<<j<<endl;
vector<int>rp;
for(int k=i;k<=j;k++){
rp.push_back(X[k]);
}
int mi=(i+j)/2;
mi=X[mi];
// cout<<i<<" "<<j<<endl;
bool sw=0;
long long b=B;
for(int k=0;k<rp.size();k++){
b-=abs(mi-rp[k]);
if(b<0){
sw=1;
break;
}
//c++;
}
if(sw==0){
// cout<<i<<" "<<j<<" "<<rp.size()<<endl;
long long tam=rp.size();
ma=max(ma,tam);
}
}
}
return ma;
}
else{*/
vector<ll>T;
T.push_back(0);
for(int i=0;i<R;i++){
T.push_back(X[i]+T[T.size()-1]);
}
for(int i=0;i<R;i++){
int l,r;
l=i;
r=R;
while(true){
if(l>r) break;
ll mi=l+(r-l)/2;
ll p=(i+mi)/2;
if((p-i)*X[p]-(T[p]-T[i])+(T[mi+1]-T[p+1])-(mi-p)*X[p]<=B){
ma=max(ma,(ll)(mi-i)+1);
l=mi;
}
else{
r=mi;
}
}
}
return ma;
//}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1093 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1096 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
768 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |