이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* Prof.Nicola
**/
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
template<class T>void re(T&x){cin>>x;}
template<class T1,class T2> void re(pair<T1,T2>&x){re(x.first);re(x.second);}
template<class T>void re(vector<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}}
template<class T>void re(deque<T>&x){for(long i=0;i<x.size();i++){re(x[i]);}}
template<class T1,class T2> pair<T1,T2> mp(T1&x,T2&z){return make_pair(x,z);}
vector<long long>v,pre;
long long cost,n;
long long calc(long long l,long long r)
{
long long mid=(l+r)/2;
long long ret=(pre[r+1]-pre[mid+1])-((r-mid)*v[mid])+(((mid-l)*v[mid])-(pre[mid]-pre[l]));
return ret;
}
long long right(long l,long r)
{
if(l==r){
return l;
}
long long z=r-l,x=l;
while(z&(z-1)){
z=z&(z-1);
}
while(z){
if(x+z<=r&&calc(l,x+z)<=cost){
x+=z;
}
z/=2;
}
return x;
}
int besthub(int R, int L, int X[], long long B)
{
cost=B;
n=R;
pre.push_back(0);
for(long i=0;i<n;i++){
v.push_back(X[i]);
}
for(long i=0;i<n;i++){
pre.push_back(pre[i]+X[i]);
}
int ans=1;
for(long i=0;i<n;i++){
ans=max(ans,(int)(right(i,n-1)-i+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... |