Submission #669090

#TimeUsernameProblemLanguageResultExecution timeMemory
669090RadicaIJob Scheduling (CEOI12_jobs)C++17
0 / 100
1089 ms12604 KiB
#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 timeMemoryGrader output
Fetching results...