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>
#define ll long long
#define INF 1000000000000
using namespace std;
vector<ll> pr, x;
int besthub(int R, int L, int X[], long long B)
{
pr.assign(R + 1, 0), x.assign(R + 1, 0);
for (int i = 1; i <= R; i++){
x[i] = X[i - 1];
pr[i] = pr[i - 1] + x[i];
}
ll ans = 0;
for (int i = 1; i <= L; i++){
ll co = 0, dist = INF;
int in = 0;
for (int j = 1; j <= R; j++){
if (abs(x[j] - i) < dist){
in = j;
dist = abs(x[j] - i);
}
}
ll l = in, r = in;
while (true){
ll col, cor;
if (l == 1){
col = INF;
}
else{
col = i - x[l - 1];
}
if (r == R){
cor = INF;
}
else{
cor = x[r + 1] - i;
}
if (co + min(col, cor) > B){
break;
}
else if (col < cor){
l--;
}
else{
r++;
}
}
ans = max(ans, r - l + 1);
}
return ans;
}
# | 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... |