# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
483151 | Zybg | Job Scheduling (CEOI12_jobs) | C++11 | 505 ms | 13744 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 <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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |