이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p[200000], bound;
int hub;
bool check(int x, int X[])
{
int m = (x-1) / 2;
if((x % 2) && (p[x-1] - p[m] - p[m-1] <= bound))
return true;
else if((x % 2 == 0) && (p[x-1] - p[m] - p[m-1] - X[m] <= bound))
return true;
for(int i = 1; i <= hub - x; i++)
{
int m = i + (x-1)/2;
if((x % 2) && (p[i+x-1] - p[m] - (p[m-1] - p[i-1]) <= bound))
return true;
else if((x % 2 == 0) && (p[i+x-1] - p[m] - (p[m-1] - p[i-1]) - X[m] <= bound))
return true;
}
return false;
}
int search(int lo, int hi, int X[])
{
int m = (lo + hi)/2;
if(lo == hi)
return lo;
if(hi == lo + 1)
m = hi;
if(check(m,X))
return search(m,hi,X);
else
return search(lo,m-1,X);
}
int besthub(int R, int L, int X[], long long B)
{
bound = B;
hub = R;
p[0] = X[0];
for(int i = 1; i < R; i++)
p[i] = p[i-1] + X[i];
return search(1,R,X);
}
# | 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... |