Submission #699403

#TimeUsernameProblemLanguageResultExecution timeMemory
699403Richw818Job Scheduling (CEOI12_jobs)C++17
100 / 100
221 ms14156 KiB
/** * 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 timeMemoryGrader output
Fetching results...