이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using db=long double;
template<class T> using V=vector<T>;
using vi = V<int>;
using vl = V<ll>;
using pi = pair<int,int>;
#define f first
#define s second
#define sz(x) (int)((x).size())
int besthub(int R, int L, int X[], ll B) {
vl pre(R+1);
vl x(R);
for (int i = 0; i < R; i++) pre[i+1] = pre[i] + (x[i]=X[i]);
int best = 1;
int l = 0, r = 1;
while (l < R) {
r = max(l+1, r);
while (r <= R) {
int m = (l+r)/2;
ll lo = pre[m]-pre[l];
ll up = pre[r]-pre[m];
lo = x[m]*(m-l) - lo;
up -= x[m]*(r-m);
if (lo + up <= B) {
best = max(best, r-l);
r += 1;
} else break;
}
l++;
}
return best;
}
| # | 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... |