# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499639 | Shreyan_Paliwal | Job Scheduling (CEOI12_jobs) | C++17 | 528 ms | 20788 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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<pair<long long, long long>> jobs;
long long n, d, m;
bool works(long long mid) {
long long counter = 0;
for (long long i = 0; i < m; i++) {
if ((counter / mid) + 1 <= jobs[i].first + d) {
counter++;
} else {
return false;
}
}
return true;
}
int main() {
// freopen("jobscheduling.in", "r", stdin);
cin >> n >> d >> m;
jobs = vector<pair<long long, long long>>(m);
for (long long i = 0; i < m; i++) {
cin >> jobs[i].first;
jobs[i].second = i + 1;
}
sort(jobs.begin(), jobs.end());
long long lo = 1;
long long hi = 1000000;
while (lo != hi) {
long long mid = (lo + hi) / 2;
if (works(mid)) {
hi = mid;
} else {
lo = mid + 1;
}
}
cout << lo << endl;
long long counter = 0;
for (long long i = 0; i < n; i++) {
if (counter < m)
for (long long j = 0; j < lo; j++) {
if (counter < m) // cout << 0 * (counter++) << " ";
cout << jobs[counter++].second << " ";
else
break;
}
cout << 0 << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |