#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(nullptr);
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(jobs.begin(), jobs.end());
auto plan = [&](int mach) -> pair<bool, vector<vector<int>>> {
vector<vector<int>> pl(n);
int idx = 0;
bool works = 1;
for (int i = 0; i < m; ++i) {
if (idx == n) {
works = 0;
break;
}
pl[idx].push_back(jobs[i].second);
if (idx > jobs[i].first + d) {
works = 0;
break;
}
if (pl[idx].size() == mach) {
++idx;
}
}
return make_pair(works, pl);
};
int lo = 1, hi = n;
while (lo < hi) {
int mi = (lo + hi) / 2;
if (plan(mi).first) {
hi = mi;
} else {
lo = mi + 1;
}
}
cout << lo << '\n';
vector<vector<int>> pl = plan(lo).second;
for (vector<int>& day : pl) {
for (int v : day) {
cout << v + 1 << ' ';
}
cout << "0\n";
}
return 0;
}
Compilation message
jobs.cpp: In lambda function:
jobs.cpp:28:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
28 | if (pl[idx].size() == mach) {
| ~~~~~~~~~~~~~~~^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
3368 KB |
Output isn't correct |
2 |
Incorrect |
23 ms |
3372 KB |
Output isn't correct |
3 |
Incorrect |
22 ms |
3324 KB |
Output isn't correct |
4 |
Incorrect |
23 ms |
3324 KB |
Output isn't correct |
5 |
Incorrect |
23 ms |
3184 KB |
Output isn't correct |
6 |
Incorrect |
24 ms |
3556 KB |
Output isn't correct |
7 |
Incorrect |
23 ms |
3448 KB |
Output isn't correct |
8 |
Incorrect |
23 ms |
3580 KB |
Output isn't correct |
9 |
Incorrect |
60 ms |
7728 KB |
Output isn't correct |
10 |
Incorrect |
61 ms |
7800 KB |
Output isn't correct |
11 |
Incorrect |
26 ms |
3196 KB |
Output isn't correct |
12 |
Correct |
49 ms |
5892 KB |
Output is correct |
13 |
Incorrect |
79 ms |
9088 KB |
Output isn't correct |
14 |
Correct |
109 ms |
13040 KB |
Output is correct |
15 |
Incorrect |
103 ms |
13508 KB |
Output isn't correct |
16 |
Correct |
179 ms |
18960 KB |
Output is correct |
17 |
Incorrect |
175 ms |
22000 KB |
Output isn't correct |
18 |
Incorrect |
224 ms |
22832 KB |
Output isn't correct |
19 |
Incorrect |
328 ms |
29552 KB |
Output isn't correct |
20 |
Incorrect |
175 ms |
22524 KB |
Output isn't correct |