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"
int besthub(int R, int L, int X[], long long B)
{
int i, be, ed, t, Res = 0;
long long S = 0;
for (i = 0; i < R; i++){
if (i == 0)be = 0, ed = 0, S = 0;
if (ed < i)be = ed = i, S = 0;
t = i * 2 - ed - 2;
if (be == t){
S -= (X[i] - X[be]);
be++;
}
t = i * 2 - ed - 1;
if (be == t){
S -= (X[i] - X[be]);
be++;
}
while (be - 1 >= 0 && ed + 1 < R){
if (S + X[ed + 1] - X[be - 1] > B)break;
S += X[ed + 1] - X[be - 1];
be--, ed++;
}
if (ed + 1 < R && S + X[ed + 1] - X[i]<= B){
S += X[ed + 1] - X[i];
ed++;
}
if (Res < ed - be + 1)Res = ed - be + 1;
if (i != R - 1 && be + ed == i * 2){
S += X[i + 1] - X[i];
}
}
return Res;
}
# | 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... |