Submission #869856

#TimeUsernameProblemLanguageResultExecution timeMemory
869856Namviet2704Rice Hub (IOI11_ricehub)C++17
Compilation error
0 ms0 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int N = 1e5 + 2; /// You can declare global variables here if necessary. /// But you are NOT allowed to write main function. vector<int> a; ll dis[N]; int r; ll money; bool check(int num) { for (int i = 1; i <= (r - num + 1); i++) { int j = i + num - 1; int mid = (j + i) / 2; ll ans = (dis[j] - dis[mid] - 1ll * a[mid] * (j - mid)) + (1ll * a[mid] * (mid - i + 1) - (dis[mid] - dis[i - 1])); // cout << i << " " << j << " " << mid << " " << ans << '\n'; if (ans <= money) return true; } return false; } /// You have to implement the below functions: int besthub(int g, int h, vector<int> x, ll b) { r = g; a.push_back(0); for (auto i : x) a.push_back(i); for (int i = 1; i <= r; i++) dis[i] = dis[i - 1] + a[i]; money = b; int low = 1, high = r, mid, ans = -1; while (low <= high) { mid = (low + high) / 2; if (check(mid)) { ans = mid; low = mid + 1; } else high = mid - 1; } return ans; } // int main() // { // vector<int> tmp = {1, 2, 10, 12, 14}; // cout << besthub(5, 20, tmp, 6); // }

Compilation message (stderr)

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