Submission #384203

#TimeUsernameProblemLanguageResultExecution timeMemory
384203kaplanbarJob Scheduling (CEOI12_jobs)C++14
15 / 100
1100 ms13676 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, d, m; cin >> n >> d >> m; vector<vector<int>> use(n); for(int i = 0; i < m; i++) { int x; cin >> x; use[x - 1].push_back(i); } vector<vector<int>> ans(n); auto check = [&](int co) -> bool { multiset<pair<int,int>> closest; for(int i = 0; i < n; i++) { ans[i].clear(); for(int x : use[i]) { closest.insert({i + d, x}); } if(!closest.empty() && closest.begin() -> first < i) return false; for(int j = 0; j < co; j++) { if(!closest.empty()) { ans[i].push_back(closest.begin() -> second); closest.erase(closest.begin()); } } } if(!closest.empty()) return false; return true; }; int l = 0, r = m; while(l + 1 < r) { int mid = (l + r) / 2; if(check(mid)) r = mid; else l = mid; } cout << r << "\n"; check(r); for(int i = 0; i < n; i++) { for(int x : ans[i]) cout << x + 1 << " "; cout << 0 << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...