Submission #1252667

#TimeUsernameProblemLanguageResultExecution timeMemory
1252667pvb.tunglamRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; /*------------- I alone decide my fate! --------------*/ static const int MAXR = 100000 + 5; static long long pref[MAXR]; // Định nghĩa C-linkage để grader (nếu là C) link được chính xác bằng tên “besthub” extern "C" int besthub(int R, int /*L*/, int X[], long long B) { // Tính pref[i] = X[0] + … + X[i] for (int i = 0; i < R; ++i) { pref[i] = X[i] + (i ? pref[i-1] : 0LL); } auto sum = [&](int l, int r) -> long long { if (l > r) return 0LL; return pref[r] - (l ? pref[l-1] : 0LL); }; int ans = 0, l = 0; for (int r = 0; r < R; ++r) { // Đẩy l lên cho tới khi cost(l,r) ≤ B while (l <= r) { int m = (l + r) >> 1; long long leftCnt = m - l; long long rightCnt = r - m; long long cost = leftCnt * X[m] - sum(l, m - 1) + sum(m + 1, r) - rightCnt * X[m]; if (cost <= B) break; ++l; } ans = max(ans, r - l + 1); } return ans; }

Compilation message (stderr)

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