#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define MAXN 100005
int n, d, m, arr[MAXN], res = 0;
vector<pair<int, int>> req;
int main(){
cin >> n >> d >> m;
FOR(i, 1, n) arr[i] = 0;
FOR(i, 1, m){
int x; cin >> x;
arr[x]++;
req.push_back({x, i});
}
sort(req.begin(), req.end());
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)){
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
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
2244 KB |
Output is correct |
2 |
Correct |
31 ms |
2252 KB |
Output is correct |
3 |
Correct |
47 ms |
2248 KB |
Output is correct |
4 |
Correct |
30 ms |
2256 KB |
Output is correct |
5 |
Correct |
30 ms |
2200 KB |
Output is correct |
6 |
Correct |
40 ms |
2204 KB |
Output is correct |
7 |
Correct |
30 ms |
2256 KB |
Output is correct |
8 |
Correct |
30 ms |
2248 KB |
Output is correct |
9 |
Incorrect |
122 ms |
2756 KB |
Output isn't correct |
10 |
Incorrect |
124 ms |
2752 KB |
Output isn't correct |
11 |
Incorrect |
33 ms |
2248 KB |
Output isn't correct |
12 |
Incorrect |
58 ms |
4176 KB |
Output isn't correct |
13 |
Incorrect |
85 ms |
6080 KB |
Output isn't correct |
14 |
Incorrect |
157 ms |
8368 KB |
Output isn't correct |
15 |
Incorrect |
142 ms |
9764 KB |
Output isn't correct |
16 |
Incorrect |
192 ms |
12972 KB |
Output isn't correct |
17 |
Incorrect |
269 ms |
14608 KB |
Output isn't correct |
18 |
Incorrect |
235 ms |
16560 KB |
Output isn't correct |
19 |
Incorrect |
350 ms |
17624 KB |
Output isn't correct |
20 |
Incorrect |
230 ms |
15024 KB |
Output isn't correct |