Submission #1216745

#TimeUsernameProblemLanguageResultExecution timeMemory
1216745takoshanavaRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define int long long #define pb push_back #define fs first #define sc second int besthub(int R, int L, int X[], long long B) { std::vector<int> pref(R + 1, 0); for (int i = 0; i < R; ++i) { pref[i + 1] = pref[i] + X[i]; } int ans = 1; int ll = 1, rr = R; while (ll <= rr) { int mid = (ll + rr) / 2; bool ok = false; for (int i = 0; i + mid <= R; ++i) { int s = i; int t = i + mid - 1; int p = (s + t) / 2; int rp = X[p]; int lcnt = p - s; int lsum = pref[p] - pref[s]; int rcnt = t - p; int rsum = pref[t + 1] - pref[p + 1]; int cost = (rp * lcnt - lsum) + (rsum - rp * rcnt); if (cost <= B) { ok = true; break; } } if (ok) { ans = mid; ll = mid + 1; } else { rr = mid - 1; } } return ans; }

Compilation message (stderr)

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