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>
#ifdef GUDEB
#define D(x) cerr << #x << ": " << (x) << '\n';
#define ifdeb if(true)
#else
#define D(x) ;
#define ifdeb if(false)
#endif
#define all(x) begin(x), end(x)
using namespace std;
using ull = unsigned long long;
using ll = long long;
// #define int ll;
int besthub(int R, int L, int X[], long long B) {
int l = 0;
int m = 0;
int r = 0;
ll c = 0;
int best = 1;
while(r < R) {
++r;
c += X[r-1] - X[m];
D(l)
D(m)
D(r)
D(c)
while(m < (l+r)/2) {
c += 1ll*(X[m+1] - X[m])*(2*m-l-r+2);
++m;
}
while(c > B) {
c -= X[m] - X[l];
++l;
while(m < (l+r)/2) {
c += 1ll*(X[m+1] - X[m])*(2*m-l-r+2);
++m;
}
}
best = max(best, r-l);
}
return best;
}
# | 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... |