#include <bits/stdc++.h>
using namespace std;
pair<int, int> t[1'000'002];
int zli[1'000'001];
int n, m, d;
bool war(int x)
{
int st_free = 1;
for (int i = 1; i <= n; i++)
{
zli[i] = 0;
}
for (int i = 1; i <= m; i++)
{
while (st_free < t[i].first || zli[st_free] == x)
{
st_free++;
}
zli[st_free]++;
if (st_free - t[i].first > d)
{
return false;
}
}
return true;
}
void ans(int x)
{
int st_free = 1;
for (int i = 1; i <= n; i++)
{
zli[i] = 0;
}
for (int i = 1; i <= m; i++)
{
if (zli[st_free] == d)
{
st_free++;
cout << "0\n";
}
while (st_free < t[i].first)
{
st_free++;
cout << "0\n";
}
zli[st_free]++;
cout << t[i].second << ' ';
}
for (; st_free <= n; st_free++)
{
cout << "0\n";
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> d >> m;
for (int i = 1; i <= m; i++)
{
cin >> t[i].first;
t[i].second = i;
}
sort (t+1, t + m+1);
int beg = 1;
int en = m;
while (beg < en)
{
int x = (beg + en)/2;
if (war(x))
{
en = x;
}
else
{
beg = x + 1;
}
}
cout << en << '\n';
ans(en);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
7764 KB |
Extra information in the output file |
2 |
Incorrect |
18 ms |
7748 KB |
Extra information in the output file |
3 |
Incorrect |
16 ms |
7680 KB |
Extra information in the output file |
4 |
Incorrect |
16 ms |
7764 KB |
Extra information in the output file |
5 |
Incorrect |
16 ms |
7764 KB |
Extra information in the output file |
6 |
Incorrect |
16 ms |
7764 KB |
Extra information in the output file |
7 |
Incorrect |
16 ms |
7720 KB |
Extra information in the output file |
8 |
Incorrect |
17 ms |
7764 KB |
Extra information in the output file |
9 |
Partially correct |
23 ms |
7656 KB |
Partially correct |
10 |
Partially correct |
22 ms |
7764 KB |
Partially correct |
11 |
Incorrect |
23 ms |
5468 KB |
Extra information in the output file |
12 |
Incorrect |
42 ms |
6600 KB |
Extra information in the output file |
13 |
Incorrect |
62 ms |
7756 KB |
Extra information in the output file |
14 |
Correct |
86 ms |
11084 KB |
Output is correct |
15 |
Incorrect |
108 ms |
14924 KB |
Extra information in the output file |
16 |
Incorrect |
140 ms |
18008 KB |
Extra information in the output file |
17 |
Correct |
146 ms |
16716 KB |
Output is correct |
18 |
Incorrect |
165 ms |
19540 KB |
Extra information in the output file |
19 |
Incorrect |
200 ms |
21324 KB |
Extra information in the output file |
20 |
Correct |
145 ms |
16716 KB |
Output is correct |