#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define MAXN 100005
#define MAXM 1000000
int n, d, m, arr[MAXN], res = 0;
pair<int, int> req[MAXM];
int main(){
cin >> n >> d >> m;
FOR(i, 1, n) arr[i] = 0;
FOR(i, 1, m){
int x; cin >> x;
arr[x]++;
req[i - 1] = {x, i};
}
sort(req, req + m - 1);
multiset<int> s; s.insert(0);
FOR(i, 1, 1 + d) s.insert(0);
FOR(i, 1, n){
res = max(res, *s.rbegin());
s.erase(s.find(*s.rbegin()));
FOR(j, 1, arr[i]){
int k = *s.begin();
s.erase(s.begin());
s.insert(k + 1);
}
s.insert(0);
}
res = max(res, *s.rbegin());
cout << res << endl;
int k = -1;
FOR(i, 1, n){
int j = 1;
while(j <= res && (k + 1 < m) && (req[k + 1].first <= i && i <= req[k + 1].first + d)){
cout << req[k + 1].second << " ";
j++, k++;
}
cout << "0" << endl;
}
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
3160 KB |
Output is correct |
2 |
Correct |
28 ms |
3160 KB |
Output is correct |
3 |
Correct |
31 ms |
3300 KB |
Output is correct |
4 |
Correct |
29 ms |
3164 KB |
Output is correct |
5 |
Correct |
29 ms |
3164 KB |
Output is correct |
6 |
Correct |
38 ms |
3156 KB |
Output is correct |
7 |
Correct |
30 ms |
3220 KB |
Output is correct |
8 |
Correct |
32 ms |
3152 KB |
Output is correct |
9 |
Incorrect |
124 ms |
3740 KB |
Output isn't correct |
10 |
Incorrect |
122 ms |
3816 KB |
Output isn't correct |
11 |
Incorrect |
28 ms |
3160 KB |
Output isn't correct |
12 |
Incorrect |
56 ms |
3776 KB |
Output isn't correct |
13 |
Incorrect |
84 ms |
6500 KB |
Output isn't correct |
14 |
Incorrect |
140 ms |
7504 KB |
Output isn't correct |
15 |
Incorrect |
138 ms |
8020 KB |
Output isn't correct |
16 |
Incorrect |
195 ms |
10884 KB |
Output isn't correct |
17 |
Incorrect |
217 ms |
11404 KB |
Output isn't correct |
18 |
Incorrect |
236 ms |
12116 KB |
Output isn't correct |
19 |
Incorrect |
346 ms |
14048 KB |
Output isn't correct |
20 |
Incorrect |
222 ms |
11604 KB |
Output isn't correct |