#include <iostream>
#include <algorithm>
using namespace std;
#define X first
#define Y second
pair<int, int> arr[1000001];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
for(int i = 0; i < m; i++)
{
cin >> arr[i].X;
arr[i].Y = i+1;
}
sort(arr, arr+m);
int l = 0, r = m;
while(l < r)
{
int mid = (l+r) / 2;
int pos = 0, i = 0;
bool ok = 1;
for(int days = 1; days <= n && ok; days++)
{
for(i = pos; i < pos+mid && i < m; i++)
{
if(arr[i].X > days)
break;
if(arr[i].X + d < days)
{
ok = 0;
break;
}
}
pos = i;
if(pos == m)
break;
}
if(ok && pos == m)
r = mid;
else
l = mid+1;
}
cout << l << '\n';
int pos = 0, i = 0;
for(int days = 1; days <= n; days++)
{
for(i = pos; i < pos+l && i < m; i++)
{
if(arr[i].X <= days)
cout << arr[i].Y << ' ';
else
break;
}
cout << "0\n";
pos = i;
if(pos == m)
continue;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
3420 KB |
Output is correct |
2 |
Correct |
12 ms |
3508 KB |
Output is correct |
3 |
Correct |
12 ms |
3420 KB |
Output is correct |
4 |
Correct |
15 ms |
3500 KB |
Output is correct |
5 |
Correct |
16 ms |
3508 KB |
Output is correct |
6 |
Correct |
12 ms |
3420 KB |
Output is correct |
7 |
Correct |
12 ms |
3552 KB |
Output is correct |
8 |
Correct |
12 ms |
3420 KB |
Output is correct |
9 |
Correct |
21 ms |
3676 KB |
Output is correct |
10 |
Correct |
21 ms |
3688 KB |
Output is correct |
11 |
Correct |
20 ms |
3588 KB |
Output is correct |
12 |
Correct |
40 ms |
4940 KB |
Output is correct |
13 |
Correct |
62 ms |
7616 KB |
Output is correct |
14 |
Correct |
84 ms |
9064 KB |
Output is correct |
15 |
Correct |
100 ms |
9808 KB |
Output is correct |
16 |
Correct |
127 ms |
13440 KB |
Output is correct |
17 |
Correct |
149 ms |
14416 KB |
Output is correct |
18 |
Correct |
165 ms |
14796 KB |
Output is correct |
19 |
Correct |
187 ms |
16724 KB |
Output is correct |
20 |
Correct |
148 ms |
14376 KB |
Output is correct |