# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
693480 | ojuzuser12 | Job Scheduling (CEOI12_jobs) | C++17 | 316 ms | 13760 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;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long 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());
long long l = 1, r = M, mid;
while(l < r) {
mid = (l + r) / 2;
bool works = ((M + mid - 1) / mid <= N);
int i = 0;
for(long long d = 0; d < N; d++) {
for(long long c = 0; c < mid; c++) {
if(d + 1 < jobs[i].first) break;
if(i >= M) break;
if(d + 1 - jobs[i].first > D) {
works = false;
break;
}
i++;
}
if(!works) break;
}
if(works) {
r = mid;
} else {
l = mid + 1;
}
}
cout << r << '\n';
int i = 0;
for(long long d = 0; d < N; d++) {
for(long long c = 0; c < r; c++) {
if(d + 1 < jobs[i].first) break;
if(i >= M) break;
cout << jobs[i].second + 1 << ' ';
i++;
}
cout << 0 << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |