# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
466123 | nehasane | Job Scheduling (CEOI12_jobs) | C++14 | 473 ms | 13724 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()
{
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].second = i;
}
sort(begin(jobs), end(jobs));
int l = 1, r = m;
while (l <= r){
int mid = (l+r) / 2;
int day = 1, i = 0, start = 0;
for (day; day <= n && i < m; day++){
for (i; i < min(m, start + mid); i++){
if (jobs[i].first + d < day && jobs[i].first >= day){
start = INT_MAX;
break;
}
}
if (start == INT_MAX)
break;
else
start = i;
}
if (start == INT_MAX || i < m)
l = mid + 1;
else
r = mid - 1;
}
cout << l << '\n';
int i = 0;
for (int day = 0; day < n; day++){
int end = i + l;
for (i; i < min(m, end); i++)
cout << jobs[i].second + 1 << ' ';
cout << 0 << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |