#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int n, d, m;
cin >> n >> d >> m;
vector<pair<int, int>> a(m + 1);
for (int i = 1; i <= m; i++) {
cin >> a[i].first;
a[i].second = i;
}
sort(a.begin(), a.end());
int l = 1, r = m;
while (l + 1 < r) {
int tm = (l + r) / 2;
bool is = 1;
int x = 1;
for (int i = 1; i <= m; ) {
int cnt = tm;
while (cnt && i <= m) {
if (a[i].first > x) break;
if (a[i].first + d < x) {
is = 0;
break;
}
i++;
cnt--;
}
if (!is) break;
x++;
}
if (is) {
r = tm;
} else {
l = tm;
}
}
cout << r << '\n';
bool is = 1;
int x = 1, j = 1;
for (int i = 1; i <= m;) {
int cnt = r;
while (cnt && i <= m) {
if (a[i].first > x) break;
cout << a[i].second << ' ';
i++;
cnt--;
}
cout << 0 << '\n';
j++;
x++;
}
for (; j <= n; j++) {
cout << 0 << endl;
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |