# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791936 | matu | Job Scheduling (CEOI12_jobs) | C++14 | 183 ms | 14544 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;
const int M = 1e6 + 1;
int n, d, m;
vector<pair<int, int>> v(M);
int main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n >> d >> m;
for(int i = 1; i <= m; i++){
cin >> v[i].first;
v[i].second = i;
}
sort(v.begin() + 1, v.begin() + 1 + m);
auto ok = [&](int nrb){
vector<int> zd;
int st = 1, dr = 1;
for(int i = 1; i <= n && st <= m && dr <= m; i++){
while(dr <= m && v[dr].first == i){
dr++;
}
dr--;
st += nrb;
if(st > m){
return 1;
}
dr = max(dr, st);
if(v[st].first + d <= i){
return 0;
}
}
return 1;
};
auto pr = [&](int nrb, int pl){
vector<int> zd;
int st = 1, dr = 1;
for(int i = 1; i <= n; i++){
while(dr <= m && v[dr].first == i){
dr++;
}
dr--;
for(int j = st; j < st + nrb; j++){
if(j > m) break;
cout << v[j].second << " ";
}
cout << 0 << '\n';
st += nrb;
dr = max(dr, st);
}
return;
};
int st = 1, dr = 1e9;
while(st <= dr){
int tm = (st + dr) / 2;
if(ok(tm)){
dr = tm - 1;
}else st = tm + 1;
}
cout << st << '\n';
pr(st, 1);
}
// 8 2 12
// 1 2 4 2 1 3 5 6 2 3 6 4
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |