# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1043802 | dpsaveslives | Job Scheduling (CEOI12_jobs) | C++17 | 1076 ms | 30800 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 f first
#define s second
using namespace std;
const int MAXN = 1e5+10;
vector<int> sched[MAXN];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N,D,M; cin >> N >> D >> M;
vector<pair<int,int>> times(M);
for(int i = 0;i<M;++i){
cin >> times[i].f;
times[i].s = i+1;
}
sort(times.begin(),times.end());
int lo = 1, hi = M; ++hi;
while(lo < hi){
int mid = lo+(hi-lo)/2;
multiset<int> machines;
for(int i = 0;i<mid;++i) machines.insert(0);
bool good = true;
for(int i = 0;i<times.size();++i){
int val = *(machines.begin());
if(val+1 < times[i].f){
val = times[i].f-1;
}
if(val+1 > times[i].f+D){
good = false;
break;
}
machines.insert(val+1);
machines.erase(machines.begin());
}
if(good){
hi = mid;
}
else{
lo = mid+1;
}
}
cout << lo << "\n";
multiset<int> machines;
for(int i = 0;i<lo;++i) machines.insert(0);
for(int i = 0;i<times.size();++i){
int val = *(machines.begin());
if(val+1 < times[i].f){
val = times[i].f-1;
}
machines.insert(val+1);
sched[val+1].push_back(times[i].s);
machines.erase(machines.begin());
}
for(int i = 1;i<=N;++i){
if(sched[i].size() == 0){
cout << 0 << "\n";
continue;
}
for(int j = 0;j<sched[i].size();++j){
cout << sched[i][j] << " ";
}
cout << 0 << "\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |