# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
556847 | Jomnoi | Job Scheduling (CEOI12_jobs) | C++17 | 212 ms | 13840 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAX_M = 1e6 + 10;
int N, D, M;
int S[MAX_M], id[MAX_M];
bool solve(int mid) {
int i = 1;
for(int days = 1; days <= N and i <= M; days++) {
if(days > S[id[i]] + D) {
break;
}
int cnt = mid;
while(i <= M and S[id[i]] <= days and cnt--) {
i++;
}
}
return i == M + 1;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cin >> N >> D >> M;
for(int i = 1; i <= M; i++) {
cin >> S[i];
id[i] = i;
}
sort(id + 1, id + M + 1, [&](const int &a, const int &b) {
return S[a] < S[b];
});
int l = 1, r = M, ans = -1;
while(l <= r) {
int mid = (l + r) / 2;
if(solve(mid) == true) {
ans = mid;
r = mid - 1;
}
else {
l = mid + 1;
}
}
cout << ans << '\n';
for(int i = 1, j = 1; i <= N; i++) {
for(int k = 0; j <= M and k < ans; j++, k++) {
cout << id[j] << ' ';
}
cout << "0\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |