# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1113984 | ezzzay | Job Scheduling (CEOI12_jobs) | C++14 | 419 ms | 20356 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>
using namespace std;
#define itn long long
#define ff first
#define ss second
#define int long long
#define pb push_back
vector<pair<int,int>>v;
int n,d,m;
bool check(int mid){
int j=0;
for(int i=1;i<=n;i++){
int p=mid;
while(j<m and p>0){
j++;
p--;
if(v[j].ff > i+d)break;
}
}
return j==m;
}
void fun(int mid){
int j=0;
for(int i=1;i<=n;i++){
int p=mid;
while(j<m and p>0){
cout<<v[j].ss<<" ";
j++;
p--;
if(v[j].ff > i+d)break;
}
cout<<0<<endl;
}
}
signed main(){
cin>>n>>d>>m;
for(int i=1;i<=m;i++){
int x;
cin>>x;
v.pb({x,i});
}
sort(v.begin(),v.end());
int lo=0,hi=1e9;
while(hi>=lo){
int mid=(hi+lo)/2;
bool u=check(mid);
if(u){
hi=mid-1;
}
else{
lo=mid+1;
}
}
cout<<hi<<endl;
fun(hi);
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |