# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
699403 | Richw818 | Job Scheduling (CEOI12_jobs) | C++17 | 221 ms | 14156 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.
/**
* Author: Richw818
* Created: 02.16.2023 16:09:58
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, d, m; cin >> n >> d >> m;
vector<vector<int>> inds(n);
for(int i = 0; i < m; i++){
int j; cin >> j;
j--;
inds[j].push_back(i);
}
auto check = [&](int machines) -> bool {
queue<int> can;
for(int day = 0; day < n; day++){
if(!can.empty() && day > can.front() + d) return false;
for(int i = 0; i < (int)inds[day].size(); i++) can.push(day);
int take = min(machines, (int)can.size());
for(int i = 0; i < take; i++) can.pop();
}
return true;
};
int l = 1, r = m + 1;
while(l < r){
int mid = (l + r) / 2;
if(check(mid)) r = mid;
else l = mid + 1;
}
cout << l << '\n';
queue<int> can;
for(int day = 0; day < n; day++){
for(int i : inds[day]) can.push(i);
int take = min((int)can.size(), l);
for(int i = 0; i < take; i++){
cout << can.front() + 1 << ' ';
can.pop();
}
cout << 0 << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |