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 <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
if(R==1)
return 1;
int mediane = X[R/2];
int l = R/2-1, r = R/2+1;
int res = 1;
while((r<R||l>=0)&&(B>=0))
{
if(l<0)
{
res++;
B-=abs(mediane-X[r]);
r++;
}
else if(r==R)
{
res++;
B-=abs(mediane-X[l]);
l--;
}
else if(abs(X[l]-mediane)<=abs(X[r]-mediane))
{
res++;
B-=abs(mediane-X[l]);
l--;
}
else if(abs(X[l]-mediane)>abs(X[r]-mediane))
{
res++;
B-=abs(mediane-X[r]);
r++;
}
}
return res-1;
}
# | 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... |