#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, d, m;
cin >> n >> d >> m;
vector <pair<int, int>> jobs(m);
for (int i = 0; i < m; i++){
cin >> jobs[i].first;
jobs[i].second = i;
}
sort(begin(jobs), end(jobs));
int l = 1, r = m;
while (l <= r){
int machines = (l+r) / 2;
int i = 0;
for (int day = 1; day <= n; day++){
for (int j = 0; j < machines; j++){
if (i >= m)
break;
if (day - jobs[i].first <= d && day >= jobs[i].first)
i++;
else
break;
}
if (i >= m)
break;
}
if (i >= m)
r = machines - 1;
else
l = machines + 1;
}
cout << l << '\n';
int i = 0;
for (int day = 1; day <= n; day++){
for (int j = 0; j < l; j++){
if (i >= m)
break;
if (day - jobs[i].first <= d && day >= jobs[i].first){
cout << jobs[i].second + 1 << ' ';
i++;
}
}
cout << 0 << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
1604 KB |
Output is correct |
2 |
Correct |
40 ms |
1596 KB |
Output is correct |
3 |
Correct |
40 ms |
1588 KB |
Output is correct |
4 |
Correct |
42 ms |
1592 KB |
Output is correct |
5 |
Correct |
46 ms |
1564 KB |
Output is correct |
6 |
Correct |
42 ms |
1612 KB |
Output is correct |
7 |
Correct |
47 ms |
1588 KB |
Output is correct |
8 |
Correct |
42 ms |
1592 KB |
Output is correct |
9 |
Correct |
55 ms |
1852 KB |
Output is correct |
10 |
Correct |
56 ms |
1848 KB |
Output is correct |
11 |
Correct |
49 ms |
1604 KB |
Output is correct |
12 |
Correct |
98 ms |
3132 KB |
Output is correct |
13 |
Correct |
164 ms |
4556 KB |
Output is correct |
14 |
Correct |
221 ms |
6116 KB |
Output is correct |
15 |
Correct |
249 ms |
7524 KB |
Output is correct |
16 |
Correct |
320 ms |
9196 KB |
Output is correct |
17 |
Correct |
374 ms |
10564 KB |
Output is correct |
18 |
Correct |
419 ms |
12056 KB |
Output is correct |
19 |
Correct |
477 ms |
13744 KB |
Output is correct |
20 |
Correct |
376 ms |
10564 KB |
Output is correct |