Submission #958292

#TimeUsernameProblemLanguageResultExecution timeMemory
958292JwFXoizJob Scheduling (CEOI12_jobs)C++14
100 / 100
283 ms21416 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define inf 0x3F3F3F3F signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, d, m; cin >> n >> d >> m; vector<int> v[n + 1]; for (int i = 1; i <= m; i++) { int x; cin >> x; v[x].push_back(i); } int l = 1, r = m; while (l < r) { int mid = (l + r) >> 1; queue<array<int, 2>> q; int ok = 1; for (int i = 1; i <= n; i++) { for (int x : v[i]) q.push({x, i}); int k = mid; while (!q.empty() && k--) q.pop(); if (!q.empty() && q.front()[1] + d == i) { ok = 0; break; } } ok &= q.empty(); if (ok) r = mid; else l = mid + 1; } cout << l << '\n'; queue<array<int, 2>> q; for (int i = 1; i <= n; i++) { for (int x : v[i]) q.push({x, i}); int k = l; while (!q.empty() && k--) { cout << q.front()[0] << ' '; q.pop(); } cout << 0 << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...