# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
530545 | Jesus | 쌀 창고 (IOI11_ricehub) | C++14 | 14 ms | 1716 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<bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
long long int precio=0,maximo=0;
int izq=0,der=0,cen=0;
int i=0,j=0;
int aux;
while(i<R){
if(j==R-1||precio>B){
if(precio<=B) maximo=max((long long int)j-i+1,maximo);
precio-=(X[cen]-X[i]);
i++;
aux=(i+j)/2;
if(aux>cen){
precio+=(X[aux]-X[cen])*(cen-i);
precio-=(X[aux]-X[cen])*(j-aux);
cen=aux;
}
}
else{
maximo=max(maximo,(long long int)(j-i)+1);
j++;
aux=(j+i)/2;
precio+=X[j]-X[aux];
if(aux>cen){
precio+=(X[aux]-X[cen])*(cen-i);
precio-=(X[aux]-X[cen])*(j-aux-1);
cen=aux;
}
}
}
return maximo;
}
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... |