#include <iostream>
#include <vector>
bool run(std::vector<std::pair<int, int>>& a, int d, int x,
std::vector<std::vector<int>>& answer) {
int i = a.size() - 1;
for (int j = a.size() - 1; j >= 0; --j) {
if (a[i].first > j) return false;
int v = x;
while (i >= 0 && v > 0 && j - a[i].first <= d) {
answer[j].push_back(a[i].second);
--i;
--v;
}
}
return true;
}
int main() {
int n, d, m;
std::cin >> n >> d >> m;
std::vector<std::pair<int, int>> a(m, {0, 0});
for (int i = 0; i < m; ++i) {
std::cin >> a[i].first;
a[i].second = i + 1;
}
std::sort(a.begin(), a.end());
int l = 0;
int r = n;
std::vector<std::vector<int>> answer;
// (l, r]
while (l + 1 < r) {
answer = std::vector<std::vector<int>>(n + 1, std::vector<int>());
int m = (l + r) / 2;
if (run(a, d, m, answer)) {
r = m;
} else {
l = m;
}
}
answer = std::vector<std::vector<int>>(n + 1, std::vector<int>());
run(a, d, r, answer);
std::cout << r << '\n';
for (int i = 1; i <= n; ++i) {
for (size_t j = 0; j < answer[i].size(); ++j) {
std::cout << answer[i][j] << ' ';
}
std::cout << "0\n";
}
}
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:32:10: error: 'sort' is not a member of 'std'
32 | std::sort(a.begin(), a.end());
| ^~~~