# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
860695 | coldy | Job Scheduling (CEOI12_jobs) | C++14 | 359 ms | 20292 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.
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
int n, d, m;
vector <int> p[(int)1e5 + 1], ans[(int)1e5 + 1];
bool ok(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(){
cin>>n>>d>>m;
for(int i = 0; i < m; i++){
int x;
cin>>x;
p[x].push_back(i + 1);
}
int lo = 1;
int hi = m;
while(lo < hi){
int mid = (lo + hi)/2;
if(ok(mid)) hi = mid;
else lo = mid + 1;
}
ok(lo);
cout<<lo<<endl;
for(int i = 1; i <= n; i++){
for(int id: ans[i]){
cout<<id<<" ";
}
cout<<0<<"\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |