Submission #861235

#TimeUsernameProblemLanguageResultExecution timeMemory
861235sleepntsheepRice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> using namespace std; #define ALL(x) x.begin(), x.end() #define N 100005 using ll = long long; int n, l, z = -1; ll b, p[N], a[N]; int optimal_hub(int l, int r) { return (l+r)/2; } ll sum(int l, int r) { return p[r] - p[l-1]; } ll need_budget(int l, int r, int h) { if (h < l || r < h) return 1e18; return a[h] * (h-l+1) - a[h] * (r-h) + sum(h+1, r) - sum(l, h); } ll need_budget(int l, int r) { return min({need_budget(l, r, optimal_hub(l, r)), need_budget(l, r, optimal_hub(l, r) + 1), need_budget(l, r, optimal_hub(l, r) - 1)}); } ll besthub(int r, int l, int *a, int b) { for (int i = 1; i <= n; ++i) { p[i] = p[i-1] + a[i]; int l = 1, r = i; while (l <= r) { int y = (l+r)/2; if (need_budget(y, i) <= b) z = max(z, i-y+1), r = y - 1; else l = y + 1; } } return z; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccdn8xs1.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