Submission #542210

#TimeUsernameProblemLanguageResultExecution timeMemory
542210jakubdJob Scheduling (CEOI12_jobs)C++17
100 / 100
483 ms30296 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, d, m; cin >> n >> d >> m; vector<pair<int, int>> a(m); for (int i = 0; i < m; i++) { cin >> a[i].first; a[i].second = i + 1; } sort(a.begin(), a.end()); vector<vector<int>> res; int lo = 1, hi = m; while (lo < hi) { int mi = (lo + hi) / 2; vector<vector<int>> cur(n + 1); queue<int> q; for (int i = 0; i < mi; i++) q.push(0); bool ok = true; for (int i = 0; i < m; i++) { if (q.front() - d <= a[i].first) { int nv = max(a[i].first, q.front()); q.pop(); q.push(nv + 1); cur[nv].push_back(a[i].second); } else { ok = false; break; } } if (ok) { hi = mi; res = cur; } else { lo = mi + 1; } } cout << lo << "\n"; for (int i = 1; i <= n; i++) { for (int x : res[i]) cout << x << " "; cout << "0\n"; } return 0; };
#Verdict Execution timeMemoryGrader output
Fetching results...