제출 #399533

#제출 시각아이디문제언어결과실행 시간메모리
399533TemmieA Difficult(y) Choice (BOI21_books)C++17
컴파일 에러
0 ms0 KiB
#include "books.h" #include <bits/stdc++.h> typedef long long ll; void solve(int n, int k, int s, ll a) { std::vector <ll> vals(n + 1, -1); ll sumfirst = 0; for (int i = 1; i <= k - 1; i++) { vals[i] = skim(i); sumfirst += vals[i]; } int l = k + 1, r = n; int best = k; while (l <= r) { int mid = (l + r) >> 1; ll now = skim(mid); vals[mid] = now; ll total = now + sumfirst; if (total >= a + a) { r = mid - 1; } else { l = mid + 1; best = mid; } } if (best == k && sumfirst + vals[best] >= a + a) { impossible(); return; } if (sumfirst + vals[best] >= a) { std::vector <int> ans; for (int i = 1; i <= k - 1; i++) ans.push_back(i); ans.push_back(best); answer(ans); return; } std::vector <int> ans; for (int i = 1; i <= k - 1; i++) ans.push_back(i); ans.push_back(best); std::set <int> have; for (int x : ans) have.insert(x); ll sum = sumfirst + vals[best]; int cur = best; for (int i = 1 - 1; i <= k - 1 - 1; i++) { sum -= vals[ans[i]]; have.erase(ans[i]); int nw = --cur; if (have.count(nw)) { impossible(); return; } have.insert(nw); if (vals[nw] == -1LL) vals[nw] = skim(nw); sum += vals[nw]; if (sum >= a) break; } std::vector <int> put; for (int x : have) put.push_back(x); answer(put); }

컴파일 시 표준 에러 (stderr) 메시지

/tmp/ccnhCeSx.o: In function `main':
grader.cpp:(.text.startup+0x7f): undefined reference to `solve(int, int, long long, int)'
collect2: error: ld returned 1 exit status