Submission #1267309

#TimeUsernameProblemLanguageResultExecution timeMemory
1267309BlockOGRice Hub (IOI11_ricehub)C++20
68 / 100
16 ms1608 KiB
#include <bits/stdc++.h>

// mrrrow meeow :3
// go play vivid/stasis now! it's free on steam

#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;

int ____init = [] {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    return 0;
}();

long long px[100001];

long long func(int start, int len) {
    return (px[start + len] - px[start + (len + 1) / 2]) - (px[start + len / 2] - px[start]);
};

int besthub(int rl, int _, int x[], long long b) {
    fo(i, 0, rl) px[i + 1] = px[i] + x[i];

    int res = 0;
    fo(i, 1, rl + 1) {
        int l = 0, r = rl - i;
        while (l < r) {
            int mid = (l + r) / 2;
            if (func(mid, i) < func(mid + 1, i)) r = mid;
            else l = mid + 1;
        }

        if (func(l, i) <= b) res = max(res, i);
    }
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...