#include <bits/stdc++.h>
using namespace std;
const int maxm = 1000000;
pair<int, int> arr[maxm];
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int n, d, m;
cin >> n >> d >> m;
for (int i = 0; i < m; i++)
{
cin >> arr[i].first;
arr[i].first--;
arr[i].second = i;
}
sort(arr, arr + m);
int l = 1, r = 2000000;
while (l < r)
{
int mid = (l + r) / 2;
int in = 0;
for (int i = 0; i < n; i++)
{
if (in != m)
if (arr[in].first < i - d)
goto A;
int ct = 0;
while (ct < mid && in < m)
{
if (arr[in].first <= i)
{
ct++;
in++;
}
else
break;
}
}
if (in == m)
{
r = mid;
continue;
}
A:;
l = mid + 1;
}
cout << l << "\n";
int in2 = 0;
for (int i = 0; i < n; i++)
{
int ct = 0;
while (ct < l && in2 < m)
{
if (arr[in2].first <= i)
{
cout << arr[in2].second + 1 << ' ';
ct++;
in2++;
}
else
break;
}
cout << "0\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
3204 KB |
Output is correct |
2 |
Correct |
20 ms |
3160 KB |
Output is correct |
3 |
Correct |
19 ms |
3300 KB |
Output is correct |
4 |
Correct |
22 ms |
3156 KB |
Output is correct |
5 |
Correct |
17 ms |
3228 KB |
Output is correct |
6 |
Correct |
14 ms |
3200 KB |
Output is correct |
7 |
Correct |
17 ms |
3132 KB |
Output is correct |
8 |
Correct |
18 ms |
3108 KB |
Output is correct |
9 |
Correct |
27 ms |
3316 KB |
Output is correct |
10 |
Correct |
25 ms |
3332 KB |
Output is correct |
11 |
Correct |
22 ms |
3200 KB |
Output is correct |
12 |
Correct |
53 ms |
3808 KB |
Output is correct |
13 |
Correct |
77 ms |
6580 KB |
Output is correct |
14 |
Correct |
108 ms |
7288 KB |
Output is correct |
15 |
Correct |
116 ms |
8092 KB |
Output is correct |
16 |
Correct |
162 ms |
10872 KB |
Output is correct |
17 |
Correct |
172 ms |
11620 KB |
Output is correct |
18 |
Correct |
220 ms |
12196 KB |
Output is correct |
19 |
Correct |
215 ms |
13904 KB |
Output is correct |
20 |
Correct |
167 ms |
11380 KB |
Output is correct |