# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
550613 | epifor | Job Scheduling (CEOI12_jobs) | C++14 | 1 ms | 212 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 <vector>
using namespace std;
#define ll long long
ll n,d,m;
ll maks = 0;
vector<pair<ll,ll>> v;
bool fjk(int k){
int dan = 1,cntr = 0;
for(int i = 0;i<m;i++){
if(cntr==k){
cntr=0;
dan++;
}
if(v[i].first>dan){
dan++;
i=i-1;
continue;
}
if(dan>v[i].first+d){
return false;
}
cntr++;
}
return true;
}
void fjk1(int k){
int dan = 0,cntr = 0;
for(int i = 0;i<m;i++){
if(cntr==k){
cntr=0;
cout << 0 << endl;
dan++;
}
cout << v[i].second+1 << " ";
cntr++;
}
cout << 0 << endl;
for(int i = dan;i<n-1;i++){
cout << 0 << endl;
}
}
int main() {
freopen("in.2","r",stdin);
cin >> n >> d >> m;
ll kl,answ=1e9;
for(int i =0;i<m;i++){
cin>>kl;
v.push_back({kl,i});
}
sort(v.begin(),v.end());
ll a = 1, b=m;
while(b>=a){
ll mid = b+(a-b)/2;
if(fjk(mid)==true){
answ=min(answ,mid);
b=mid-1;
}else{
a=mid+1;
}
}
cout << answ << endl;
fjk1(answ);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |