# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234050 | DanerZein | Rice Hub (IOI11_ricehub) | C++14 | 1093 ms | 1912 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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++){
for(int j=i+1;j<R;j++){
ll mi=(i+j)/2;
if((mi-i)*X[mi]-(T[mi]-T[i])+(T[j+1]-T[mi+1])-(j-mi)*X[mi]<=B){
ma=max(ma,(ll)(j-i)+1);
}
}
}
return ma;}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |