# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
961019 | ankit_singh_programs | Job Scheduling (CEOI12_jobs) | C++14 | 1077 ms | 2548 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>
using namespace std;
#define ll long long
ll k;
#define str string
void io(str s){
str s1=s+".in";
str s2=s+".out";
freopen(s1.c_str(),"r",stdin);
freopen(s2.c_str(),"w",stdout);
}
#define de(x) cout<<#x<<" ";cout<<x<<endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int day,del,n;
#include <bits/stdc++.h>
#define ve vector
ve<pair<int,int>> ar;
#define f first
#define s second
bool chk(int k){
int a;
int c;
a=1;
c=0;
for(auto nxt:ar){
int v=nxt.f;
while(a<v){
++a;
c=0;
}
if(a>day) return 0;
int dt=fabs(a-v);
if(dt>del) return 0;
++c;
if(c==k){
c=0;
++a;
}
}
return 1;
}
const int inf=1e9;
#define pb push_back
#define all(x) (x).begin(),(x).end()
void sol(){
cin>>day>>del>>n;
for(int i=0;i<n;++i){
int a;
cin>>a;
ar.pb({a,i+1});
}
sort(all(ar));
int l=1;
int r=n;
int ans=inf;
while(l<=r){
int m=(l+r)/2;
if(chk(m)){
ans=m;
r=m-1;
}
else{
l=m+1;
}
}
// case t+ fasth
cout<<ans;
cout<<endl;
int k=ans;
int a,c;
a=1;
c=0;
bool don=0;
for(auto nxt:ar){
int v=nxt.f;
while(a<v){
cout<<"0\n";
++a;
c=0;
}
int dt=fabs(a-v);
++c;
cout<<nxt.second<<" ";
if(c==k){
don=1;
cout<<"0"<<endl;
c=0;
++a;
}
}
if(don);
else{
cout<<0<<endl;
++a;
}
a=day-a;
++a;
while(a--) cout<<0<<endl;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
freopen("error.txt","w",stderr);
#endif
// io("cbarn2");
sol();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |