#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
vector<int> v (n+1, 0), sp (n+1, 0);
vector<vector<int>> c (n+1);
for (int i = 1; i < m+1; i++) {
int x;
cin >> x;
v[x]++;
c[x].push_back(i);
}
vector<int> s;
for (auto i : c) {
for (int x : i) {
s.push_back(x);
}
}
for (int i = 1; i < n+1; i++) {
sp[i] = sp[i-1]+v[i];
}
int p = 0, j = 1<<20;
while (j > 0) {
int k = p+j;
int wyk = 0;
bool b = 1;
for (int i = 1; i < n+1; i++) {
wyk = min(wyk+k, sp[i]);
if (i > d+1 && wyk < sp[i-d-1]) {
b = 0;
break;
}
}
if (!b) {
p += j;
}
j /= 2;
}
cout << p+1 << '\n';
int k = p+1, nr = 0;
int wyk = 0;
for (int i = 1; i < n+1; i++) {
wyk = min(wyk+k, sp[i]);
while (nr < wyk) {
cout << s[nr]+1 << ' ';
nr++;
}
cout << "0\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
2256 KB |
Output isn't correct |
2 |
Incorrect |
10 ms |
2260 KB |
Output isn't correct |
3 |
Incorrect |
10 ms |
2256 KB |
Output isn't correct |
4 |
Incorrect |
10 ms |
2260 KB |
Output isn't correct |
5 |
Incorrect |
18 ms |
2260 KB |
Output isn't correct |
6 |
Incorrect |
10 ms |
2260 KB |
Output isn't correct |
7 |
Incorrect |
10 ms |
2260 KB |
Output isn't correct |
8 |
Incorrect |
11 ms |
2260 KB |
Output isn't correct |
9 |
Incorrect |
26 ms |
5420 KB |
Output isn't correct |
10 |
Incorrect |
24 ms |
5348 KB |
Output isn't correct |
11 |
Incorrect |
15 ms |
2004 KB |
Integer 100001 violates the range [0, 100000] |
12 |
Incorrect |
21 ms |
3572 KB |
Integer 200001 violates the range [0, 200000] |
13 |
Incorrect |
43 ms |
5844 KB |
Output isn't correct |
14 |
Incorrect |
57 ms |
7616 KB |
Integer 400001 violates the range [0, 400000] |
15 |
Incorrect |
56 ms |
8824 KB |
Output isn't correct |
16 |
Incorrect |
76 ms |
11196 KB |
Integer 600001 violates the range [0, 600000] |
17 |
Incorrect |
96 ms |
13500 KB |
Output isn't correct |
18 |
Incorrect |
86 ms |
14012 KB |
Output isn't correct |
19 |
Incorrect |
99 ms |
17896 KB |
Output isn't correct |
20 |
Incorrect |
95 ms |
13500 KB |
Output isn't correct |