#include <bits/stdc++.h>
using namespace std;
int main() {
int N, D, M;
cin >> N >> D >> M;
vector<int> jobRequests(M);
for (int i = 0; i < M; ++i) {
cin >> jobRequests[i];
}
vector<int> jobsPerDay(N + 1, 0);
for (int i = 0; i < M; ++i) {
jobsPerDay[jobRequests[i]]++;
}
priority_queue<int, vector<int>, greater<int>> availableMachines;
int maxMachines = 0;
vector<vector<int>> schedule(N + 1);
for (int day = 1; day <= N; ++day) {
while (!availableMachines.empty() && availableMachines.top() < day) {
availableMachines.pop();
}
for (int job = 0; job < jobsPerDay[day]; ++job) {
if (availableMachines.empty() || availableMachines.top() > day + D) {
maxMachines++;
availableMachines.push(day + D);
} else {
int nextAvailableDay = availableMachines.top();
availableMachines.pop();
availableMachines.push(nextAvailableDay + 1);
}
schedule[day].push_back(day);
}
}
cout << maxMachines << endl;
for (int day = 1; day <= N; ++day) {
for (int job : schedule[day]) {
cout << job << " ";
}
cout << "0" << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
33 ms |
2272 KB |
Partially correct |
2 |
Partially correct |
42 ms |
2424 KB |
Partially correct |
3 |
Partially correct |
34 ms |
2436 KB |
Partially correct |
4 |
Partially correct |
34 ms |
2436 KB |
Partially correct |
5 |
Partially correct |
34 ms |
2192 KB |
Partially correct |
6 |
Partially correct |
35 ms |
2276 KB |
Partially correct |
7 |
Partially correct |
34 ms |
2436 KB |
Partially correct |
8 |
Partially correct |
34 ms |
2400 KB |
Partially correct |
9 |
Incorrect |
135 ms |
4692 KB |
Output isn't correct |
10 |
Incorrect |
132 ms |
4684 KB |
Output isn't correct |
11 |
Incorrect |
25 ms |
2136 KB |
Output isn't correct |
12 |
Incorrect |
47 ms |
3668 KB |
Output isn't correct |
13 |
Incorrect |
70 ms |
5884 KB |
Output isn't correct |
14 |
Incorrect |
116 ms |
8372 KB |
Output isn't correct |
15 |
Incorrect |
120 ms |
9040 KB |
Output isn't correct |
16 |
Incorrect |
169 ms |
12244 KB |
Output isn't correct |
17 |
Incorrect |
194 ms |
14676 KB |
Output isn't correct |
18 |
Incorrect |
200 ms |
14032 KB |
Output isn't correct |
19 |
Incorrect |
317 ms |
17764 KB |
Output isn't correct |
20 |
Incorrect |
201 ms |
14540 KB |
Output isn't correct |