# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
713903 | iskhakkutbilim | Job Scheduling (CEOI12_jobs) | C++14 | 239 ms | 13776 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;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
int n, m, k;
vector<pair<int, int> > job;
main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> k;
job.resize(k);
for(int i = 0;i < k; i++){
cin >> job[i].ff;
job[i].ss = i;
}
sort(all(job));
function<int(int, int)> good=[&](int machine, int pr){
int j = 0;
for(int i = 1;i <= n; i++){
int cnt = 0;
// if(i > n-m){
// if(pr) cout << 0 << '\n';
// }else{
while(cnt < machine && j < k){
if(i > m + job[j].ff) return 0;
if(pr) cout << job[j].ss+1 << ' ';
j++, cnt++;
}
if(pr) cout << 0 << '\n';
// }
}
if(j < k) return 0;
return 1;
};
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
int l = 0, r = (int)1e6 + 1;
while(l + 1 < r){
int mid = (l + r)>>1;
if(good(mid, 0)){
r = mid;
}else{
l = mid;
}
}
cout << r << '\n';
good(r, 1);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |