# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
532891 | louiskwok | Job Scheduling (CEOI12_jobs) | C++17 | 448 ms | 13636 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;
struct Job {
int id;
int day;
bool operator<(const Job arb) const { return day < arb.day; }
} job[1000005];
int n,d,m;
bool possible(int x) {
int daycnt = 0;
int it = 1;
while (it<=m) {
int cnt = 0;
daycnt++;
for (;it<=m&&cnt<x;it++) {
if (job[it].day+d<daycnt) return false;
cnt++;
}
}
if (daycnt>n) return false;
return true;
}
int main() {
cin >> n >> d >> m;
for (int i=1;i<=m;i++) {
cin >> job[i].day;
job[i].id = i;
}
sort(job+1,job+m+1);
int lo = 1,hi = 1000000;
while (lo<hi) {
int mid = lo+(hi-lo)/2;
if (possible(mid)) hi = mid;
else lo = mid+1;
}
cout << lo << endl;
int it = 1;
int daycnt = 0;
while (it<=m) {
daycnt++;
int cnt = 0;
for (;it<=m&&cnt<lo;it++) {
cnt++;
cout << job[it].id << ' ';
}
cout << 0 << endl;
}
for (int i=daycnt;i<n;i++) cout << 0 << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |