#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define ll long long
int besthub(int R, int L, int X[], long long B)
{
int maxx = 0;
int begg = 0, endd = -1;
int midd = -1;
int parity = 1;
ll cost = 0;
int rice_amount = 0;
while (true)
{
if (parity) midd++;
parity ^= 1;
if (cost <= B)
{
maxx = max(maxx, rice_amount);
endd++;
if (endd == R) break;
rice_amount++;
cost += X[endd] - X[midd];
}
else
{
cost -= X[midd] - X[begg];
begg++;
rice_amount--;
}
}
return maxx;
}
| # | 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... |