Submission #418366

# Submission time Handle Problem Language Result Execution time Memory
418366 2021-06-05T10:21:39 Z temurbek_khujaev Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;


int besthub(int R, int L, long long X[], long long B) {
    int ans = 0;
    vector<long long> pref(R, 0);
    for (int i = 0; i < R; i++) {
        pref[i] = i == 0 ? X[0] : pref[i - 1] + X[i];
    }
    for (int i = 0; i < R; i++) {
        int l = 1, r = R;
        while (l <= r) {
            int m = (l + r) >> 1;
            int left = i - m / 2 + 1;
            int right = i + (m + 1) / 2;
            bool good = false;
            if (left >= 0 && right < R) {
                long long s = 0;
                assert(right - left + 1 == m);
                for (int j = left; j <= right; j++) {
                    s += abs(X[i] - X[j]);
                }
                good = s <= B;
//                long long d1 = pref[right] - pref[i] - (i + 1) * 1ll * X[i];
//                long long d2 = (X[i] - X[left]) * (m / 2) - pref[i] + left == 0 ? 0 : pref[left - 1];
//                good = d1 + d2 <= B;
            }


            if (good) {
                l = m + 1;
                ans = max(ans, m);
                cout << left << ' ' << i << ' ' << right << endl;
            } else r = m - 1;
        }


    }


    return ans;
}

Compilation message

/usr/bin/ld: /tmp/ccmcbK0D.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status