# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1043805 | dpsaveslives | Job Scheduling (CEOI12_jobs) | C++17 | 189 ms | 20076 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;
vector<int> machines(mid,0);
bool good = true;
for(int i = 0;i<times.size();++i){
if(machines[i%mid]+1 > times[i].f+D){
good = false;
break;
}
machines[i%mid] = max(machines[i%mid]+1,times[i].f);
}
if(good){
hi = mid;
}
else{
lo = mid+1;
}
}
cout << lo << "\n";
vector<int> machines(lo,0);
for(int i = 0;i<times.size();++i){
machines[i%lo] = max(machines[i%lo]+1,times[i].f);
//cout << machines[i%lo] << " " << times[i].f << "\n";
sched[machines[i%lo]].push_back(times[i].s);
}
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... |