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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
int N, L, X[MAXN+10], ans=1;
ll B;
int besthub(int RR, int LL, int XX[], ll BB)
{
int i, j;
N=RR; L=LL; B=BB;
for(i=0; i<N; i++) X[i]=XX[i];
ll cost=0;
int lp=0, rp=0;
for(; lp<N; lp++)
{
//printf("%d %d %lld\n", lp, rp, cost);
for(; rp<N && cost<=B; rp++)
{
//printf("%d %d %lld\n", lp, rp, cost);
ans=max(ans, rp-lp+1);
int mid=(lp+rp+1)>>1;
cost+=X[rp+1]-X[mid];
}
//printf("%d %d %lld\n", lp, rp, cost);
int mid=(lp+rp+1)>>1;
cost-=X[mid]-X[lp];
}
return ans;
}
Compilation message (stderr)
ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:15:12: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
# | 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... |