# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
556845 | Jomnoi | Job Scheduling (CEOI12_jobs) | C++17 | 212 ms | 13892 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 days = 1, cnt = mid;
for(int i = 1; i <= M; i++) {
if(days > S[id[i]] + D) {
return false;
}
cnt--;
if(cnt == 0) {
cnt = mid;
days++;
}
}
return days <= N;
}
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... |