Submission #1128370

#TimeUsernameProblemLanguageResultExecution timeMemory
1128370lucaskojimaRice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "ricehub.h" #define int long long using namespace std; int besthub(int n, int x, int vv[], int c) { vector<int> v(n + 1); for (int i = 1; i <= n; i++) v[i] = vv[i - 1]; vector<int> pref(n + 1); for (int i = 1; i <= n; i++) pref[i] = pref[i - 1] + v[i]; auto ok = [&](int k) -> bool { for (int l = 1, r = k; r <= n; l++, r++) { int m = (l + r) / 2; int sumL = pref[m - 1] - pref[l - 1]; int sumR = pref[r] - pref[m]; int cost = abs(v[m] * (m - l) - sumL) + abs(sumR - v[m] * (r - m)); if (cost <= c) return true; } return false; }; int l = 1; // l is good int r = n + 1; // r is bad while (r > l + 1) { int m = (l + r) / 2; ok(m) ? l = m : r = m; } return l; }

Compilation message (stderr)

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