Submission #483151

#TimeUsernameProblemLanguageResultExecution timeMemory
483151ZybgJob Scheduling (CEOI12_jobs)C++11
100 / 100
505 ms13744 KiB
#include <iostream> #include <algorithm> #include <array> using namespace std; int n,d,m; array<int,2> a[1000010]; bool check(int x){ int i=1,j=1; for(;i<=n;i++){ int cur = 1; while(a[j][0]<=i && j<=m && cur<=x){ if(i-d>a[j][0]) return 0; j++,cur++; } } if(j<m) return 0; return 1; } void calc(int r){ for(int i=1,j=1;i<=n;i++){ int cur = 1; while(a[j][0]<=i && j<=m && cur<=r){ cout << a[j][1] << " "; j++,cur++; } cout << 0 << endl; } } int main(){ cin >> n >> d >> m; for(int i=1;i<=m;i++){ cin >> a[i][0]; a[i][1] = i; } sort(a+1,a+m+1); int l = 1, r = 1000010; while(l<r){ int mid = (l+r)/2; if(check(mid)) r = mid; else l = mid+1; } cout << r << endl; calc(r); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...