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 "ricehub.h"
#include<bits/stdc++.h>
///Median
///Sliding window
///Determine the maximum number of reachable rice fields
using namespace std;
typedef long long ll;
#define debug(x) cout<<#x<<" = "<<x<<endl
int besthub(int N, int L, int X[], ll B)
{
ll cost=0;
int a=0,b=0;
int maximum=0;
while(b<N){
int mid;
if(cost<=B){
maximum=max(maximum,b-a+1);
b++;
mid=(a+b)/2;
if(b<N)
cost+=X[b]-X[mid];
}
else{
a++;
mid=(a+b)/2;
cost-=X[mid]-X[a-1];
}
}
return maximum;
}
# | 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... |