이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll r,l,b;
ll qs[100010]={};
ll get_dist(ll st,ll ed)
{
ll mid=(st+ed)>>1;
ll med=qs[mid+1]-qs[mid];
return med*((ed-st+1)&1ll)+(qs[ed+1]-qs[mid+1])-(qs[mid+1]-qs[st]);
}
ll hi,low,av;
bool test_b(ll k)
{
for(ll i=0;i<=r-k;i++)
{
if(get_dist(i,i+k-1)<=b) return true;
}
return false;
}
int besthub(int R, int L, int X[], long long B)
{
r=(ll)R;
l=(ll)L;
b=B;
for(int i=0;i<r;i++)
{
qs[i+1]=qs[i]+(ll)X[i];
}
hi=r;
low=1;
while(hi>low)
{
av=(hi+low+1)>>1;
if(test_b(av)) low=av;
else hi=av-1;
}
return (int)hi;
}
| # | 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... |