This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///
/// There's a reason for your defeat, DIO. One simple reason...
/// You pissed me off.
///
#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x,l,r) for(ll x = ll(r)-1; x >= ll(l); --x)
#define Kill(x) exit((cout << (x) << '\n', 0))
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
using namespace std;
#ifndef DARD
#include "ricehub.h"
#endif
int besthub(int r, int l, int x[], long long b)
{
int ans = 0;
ll cur = 0;
for (int i=0, j=0; j < r;) {
cur += x[j++];
cur -= x[(j+i-1)/2];
// cout << i << ' ' << j << ' ' << cur << '\n';
while (cur > b) {
cur += x[i++];
cur -= x[(j+i-1)/2];
}
// cout << i << ' ' << j << ' ' << cur << '\n';
ans = max(ans, j-i);
}
return ans;
}
#ifdef DARD
int main()
{
int constexpr r = 5;
int constexpr l = 20;
ll constexpr b = 6;
int x[] = {1, 2, 10, 12, 14};
cout << besthub(r, l, x, b) << '\n';
}
#endif
# | 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... |