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>
using namespace std;
long long r=0, curr=0, cnt=0, res=0, i, mid, b;
int* x;
bool check(){
if((r-i)%2){
if(curr+x[r+1]-x[mid]<=b){
curr+=x[r+1]-x[mid];
cnt++;
return true;
}
return false;
}
else{
if(curr+(x[mid+1]-x[mid])+x[r+1]-x[mid+1]<=b){
curr+=(x[mid+1]-x[mid])+x[r+1]-x[mid+1];
cnt++;
mid++;
return true;
}
return false;
}
}
int besthub(int R, int L, int X[], long long B){
x=X;
b=B;
for(i=0; i<R; i++){
r=max(r, i);
if(i==r){
mid=i;
curr=0;
cnt=1;
}
while(r+1<R && check()){
res=max(res, cnt);
r++;
}
}
return res;
}
# | 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... |