# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
669090 | RadicaI | Job Scheduling (CEOI12_jobs) | C++17 | 1089 ms | 12604 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;
using ll = long long;
int main(){
int n,d,p; cin >> n>>d>>p;
map<int, vector<int> > conv;
int jobs[p]; for(int i=0; i<p; i++){cin >> jobs[i]; conv[jobs[i]].push_back(i+1);}
sort(jobs, jobs+p);
int l=1; int r = 1e6;
int ans=-1;
while(l<r){
int m = 2;
int day=0;
int counter=0;
bool check=true;
for(int i=0; i<p; i++){
if(jobs[i] > day){day = jobs[i]; counter=1;}
else{
if(counter==m){
day++;
counter=0;
}
if(day-jobs[i] >d) check=false;
counter++;
}
}
if(check){r=m-1; ans=m;}
else l=m;
}
cout << ans<<endl;
int day=1;
int coun=0;
for(int i=0; i<p; i++){
if(jobs[i]>day){
for(int k=day; k<jobs[i]; k++) cout << 0<<endl;
day = jobs[i];
coun=1;
cout << conv[jobs[i]][0] << " ";
conv[jobs[i]].erase(conv[jobs[i]].begin());
}else{
if(coun == ans){
day++; coun=0; cout << 0 <<endl;
}
cout << conv[jobs[i]][0] << " ";
coun++;
conv[jobs[i]].erase(conv[jobs[i]].begin());
}
}for(int i=day; i<=n; i++) cout << 0 <<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |