#include <bits/stdc++.h>
using namespace std;
int day, deadline, work;
const int N = 100001;
int workday[N] = {};
vector<int> general;
vector<int> li[N] = {};
bool solve(int maxmachine)
{
int workleft = work;
int dayy = 1;
vector<int> soil = general;
while (workleft > 0 && !soil.empty())
{
for (int i = 0; i < maxmachine; ++i)
{
if (soil.back() + deadline < dayy)
return false;
else
{
workleft--;
soil.pop_back();
}
}
dayy++;
}
return true;
}
bool solveprint(int maxmachine)
{
int workleft = work;
int dayy = 1;
vector<int> soil = general;
while (workleft > 0 && !soil.empty())
{
for (int i = 0; i < maxmachine; ++i)
{
if (soil.back() + deadline < dayy)
return false;
else
{
cout << li[soil.back()].back() << " ";
li[soil.back()].pop_back();
workleft--;
soil.pop_back();
}
}
dayy++;
cout << "0\n";
}
for(int i = dayy;i <= day;++i)
cout << "0\n";
return true;
}
int main()
{
int a;
cin >> day >> deadline >> work;
for (int i = 0; i < work; ++i)
{
cin >> a;
workday[a]++;
li[a].push_back(i+1);
}
int maxwork = -1;
for (int i = 1; i <= day - deadline; ++i)
{
maxwork = max(maxwork, workday[i]);
for (int j = 1; j <= workday[i]; ++j)
general.push_back(i);
}
reverse(general.begin(), general.end());
int l;
for(int i = 1;i <= work;++i)
{
if(solve(i))
{
l = i;
break;
}
}
cout << l << "\n";
solveprint(l);
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:85:18: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
85 | cout << l << "\n";
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
262 ms |
4432 KB |
Output isn't correct |
2 |
Incorrect |
265 ms |
4336 KB |
Output isn't correct |
3 |
Incorrect |
256 ms |
4340 KB |
Output isn't correct |
4 |
Incorrect |
146 ms |
4348 KB |
Output isn't correct |
5 |
Incorrect |
121 ms |
4432 KB |
Output isn't correct |
6 |
Incorrect |
141 ms |
4340 KB |
Output isn't correct |
7 |
Incorrect |
143 ms |
4332 KB |
Output isn't correct |
8 |
Incorrect |
88 ms |
4416 KB |
Output isn't correct |
9 |
Incorrect |
152 ms |
4864 KB |
Output isn't correct |
10 |
Incorrect |
197 ms |
4844 KB |
Output isn't correct |
11 |
Incorrect |
35 ms |
4548 KB |
Output isn't correct |
12 |
Correct |
68 ms |
6504 KB |
Output is correct |
13 |
Incorrect |
125 ms |
9212 KB |
Output isn't correct |
14 |
Correct |
144 ms |
11068 KB |
Output is correct |
15 |
Incorrect |
230 ms |
12968 KB |
Output isn't correct |
16 |
Incorrect |
215 ms |
15476 KB |
Output isn't correct |
17 |
Incorrect |
248 ms |
18248 KB |
Output isn't correct |
18 |
Incorrect |
387 ms |
18904 KB |
Output isn't correct |
19 |
Incorrect |
492 ms |
20512 KB |
Output isn't correct |
20 |
Incorrect |
267 ms |
18148 KB |
Output isn't correct |