# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
860679 | agawron | Job Scheduling (CEOI12_jobs) | C++14 | 279 ms | 21228 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<cstdio>
#include<vector>
using namespace std;
const int MAX_N = 1e5 + 5;
int n, d, m;
vector <int> p[MAX_N], ans[MAX_N];
bool check(int x){
for(int i = 1; i <= n; i++) ans[i].clear();
for(int i = 1, idx = 1 ; i <= n; idx = max(idx, ++i)){
for(int id: p[i]){
if(ans[idx].size() == x) idx++;
if(idx > i + d) return 0;
ans[idx].push_back(id);
}
}
return 1;
}
int main(){
scanf("%d %d %d", &n, &d, &m);
for(int i = 0; i < m; i++){
int x;
scanf("%d", &x);
p[x].push_back(i + 1);
}
int lo = 1;
int hi = m;
int mi;
while(lo < hi){
mi = (lo + hi)/2;
if(check(mi)) hi = mi;
else lo = mi + 1;
}
check(lo);
printf("%d\n", lo);
for(int i = 1; i <= n; i++){
for(int id: ans[i]){
printf("%d ", id);
}
puts("0");
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |