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>
# define ll long long
using namespace std;
int l, r, pos;
ll pc[200001], val;
void ad() {
r++;
val += pc[r] - pc[pos];
if((r - l + 1)&1) {
// dimajuin pos nya
val -= pc[pos + 1] - pc[pos];
pos++;
}
return;
}
void mn() {
val -= pc[pos] - pc[l];
l++;
if((r - l + 1)&1) {
// dimajuin pos nya
val -= pc[pos + 1] - pc[pos];
pos++;
}
}
int besthub(int R, int L, int X[], ll B) {
for(int i=0;i<R;i++) pc[i] = X[i];
val = 0ll;
l = r = pos= 0;
int mx = 0;
for(int i=1;i<R;i++) {
ad();
while(val > B) mn();
mx = max(mx, r - l + 1);
}
return mx;
}
# | 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... |