Submission #554887

#TimeUsernameProblemLanguageResultExecution timeMemory
554887Genius3435Job Scheduling (CEOI12_jobs)C++17
40 / 100
267 ms16868 KiB
#include <bits/stdc++.h> using namespace std; constexpr int N = 100005; constexpr int M = 1000005; vector<int> ids[N]; int n, d, m; bool test(int c, bool print=false) { queue<pair<int, int>> q; // stores {day, id} for (int i = 1; i <= n; ++i) { for (const int id : ids[i]) q.emplace(i, id); for (int j = 0; j < c && !q.empty(); ++j) { if (print) printf("%d ", q.front().second); q.pop(); } if (print) printf("0\n"); if (!q.empty() && q.front().first < i-d) return false; } return q.empty(); } int main() { cin.tie(nullptr)->sync_with_stdio(false); cin >> n >> d >> m; for (int x, i = 1; i <= m; ++i) { cin >> x; ids[x].push_back(i); } int l = 1, r = m; while (l < r) { const int md = l + (r-l)/2; if (test(md)) r = md; else l = md+1; } printf("%d\n", l); test(l, true); }
#Verdict Execution timeMemoryGrader output
Fetching results...