# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
918277 | Aiperiii | Job Scheduling (CEOI12_jobs) | C++14 | 291 ms | 16680 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>
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,m,d;
cin>>n>>d>>m;
vector <pair <int,int> > v;
for(int i=0;i<m;i++){
int x;cin>>x;
v.pb({x,i+1});
}
sort(all(v));
//for(auto x : v)cout<<x.ff<<" "<<x.ss<<"\n";
int l=0,r=1e6+5;
while(l+1<r){
int md=(l+r)/2;
int p=0;
for(int i=1;i<=n;i++){
int cnt=md;
while(cnt>0 && p<v.size() && v[p].ff<=i && v[p].ff>=i-d){
cnt--;
p++;
}
//cout<<p<<"\n";
}
//cout<<md<<" "<<p<<"\n";
if(p==v.size())r=md;
else l=md;
}
cout<<r<<"\n";
int p=0;
for(int i=1;i<=n;i++){
int cnt=r;
while(cnt>0 && p<v.size() && v[p].ff<=i && v[p].ff>=i-d){
cnt--;
cout<<v[p].ss<<" ";
p++;
}
cout<<0<<"\n";
}
}
/*
8 2 12
1 2 3 4 5 6 7 8 9 10 11 12
1 2 4 2 1 3 5 6 2 3 6 4
1 3 5 2 1 4 5 6 2 3 6 4
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |