Submission #224587

# Submission time Handle Problem Language Result Execution time Memory
224587 2020-04-18T13:12:26 Z my99n Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

long long s[100100];

int sum(int l, int r) {
    if (l == 0) return s[r];
    return s[r] - s[l - 1];
}

int besthub(int n, int L, int x[], long long b) {
    s[0] = x[0];
    for (int i = 1; i < n; i++) s[i] = 0;
    for (int i = 1; i < n; i++) s[i] = x[i] + s[i - 1];
    int l = 0, r = 0, ans = 1;

    for (int i = 0; i < n; i++) {
        int l = 0, r = n - 1;
        while (l < r) {
            int mid = (l + r) / 2;
            int med = (i + mid) / 2;
            int left = s[med] * (med - i + 1) - sum(i, med);
            int right = sum(med + 1, mid) - s[med] * (mid - med);
            if (left + right > b)
                r = mid;
            else
                l = mid + 1;
        }
        ans = max(ans, l - i + 1);
    }
    return ans;
}

int main() {
    int n, l, b;
    scanf("%d %d %d", &n, &l, &b);
    int x[n];
    for (int i = 0; i < n; i++) scanf("%d", &x[i]);
    printf("%d", besthub(n, l, x, b));
}

Compilation message

ricehub.cpp:2:10: fatal error: grader.h: No such file or directory
 #include "grader.h"
          ^~~~~~~~~~
compilation terminated.