#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].first;
jobs[i].second = i + 1;
}
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 << ' ';
}
cout << "0\n";
}
return 0;
}
Compilation message
jobs.cpp: In lambda function:
jobs.cpp:29:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
29 | if (pl[idx].size() == mach) {
| ~~~~~~~~~~~~~~~^~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
3148 KB |
Output isn't correct |
2 |
Incorrect |
25 ms |
3144 KB |
Output isn't correct |
3 |
Incorrect |
25 ms |
3168 KB |
Output isn't correct |
4 |
Incorrect |
23 ms |
3024 KB |
Output isn't correct |
5 |
Incorrect |
26 ms |
3016 KB |
Output isn't correct |
6 |
Incorrect |
27 ms |
3020 KB |
Output isn't correct |
7 |
Incorrect |
24 ms |
3424 KB |
Output isn't correct |
8 |
Incorrect |
22 ms |
3224 KB |
Output isn't correct |
9 |
Correct |
56 ms |
7444 KB |
Output is correct |
10 |
Correct |
58 ms |
7528 KB |
Output is correct |
11 |
Correct |
23 ms |
2672 KB |
Output is correct |
12 |
Correct |
51 ms |
4996 KB |
Output is correct |
13 |
Correct |
75 ms |
7872 KB |
Output is correct |
14 |
Correct |
105 ms |
11184 KB |
Output is correct |
15 |
Incorrect |
122 ms |
11720 KB |
Output isn't correct |
16 |
Correct |
169 ms |
16072 KB |
Output is correct |
17 |
Correct |
198 ms |
19112 KB |
Output is correct |
18 |
Correct |
248 ms |
19840 KB |
Output is correct |
19 |
Correct |
295 ms |
26188 KB |
Output is correct |
20 |
Correct |
210 ms |
19144 KB |
Output is correct |