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 <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <chrono>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <queue>
#include <bitset>
#include <cmath>
#include <cassert>
typedef long long ll;
typedef long double ld;
using namespace std;
const int maxr = 1e5 + 5;
ll pf[maxr];
ll sum(int l, int r)
{
return pf[r + 1] - pf[l];
}
bool check(int r, int l, ll b, int k)
{
for (int i = 0; i + k <= r; i++)
{
ll s = sum(i + k - k / 2, i + k - 1) - sum(i, i + k / 2 - 1);
if (s <= b) return true;
}
return false;
}
int besthub(int r, int l, int x[], ll b)
{
for (int i = 0; i <= r; i++) pf[i + 1] = pf[i] + x[i];
int lo = 1, hi = r;
while (lo < hi)
{
int mi = (lo + hi + 1) / 2;
if (check(r, l, b, mi)) lo = mi;
else hi = mi - 1;
}
return lo;
}
# | 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... |