제출 #1271038

#제출 시각아이디문제언어결과실행 시간메모리
1271038ramzialoulouJob Scheduling (CEOI12_jobs)C++20
60 / 100
216 ms13784 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, d, m; cin >> n >> d >> m; vector<pair<int, int>> a(m); for (int i = 0; i < m; i++) { int x; cin >> x; a[i] = {x, i}; } sort(a.begin(), a.end()); auto check = [&](int k) { queue<int> q; int i = 0; for (int day = 1; day <= n; day++) { while (i < m && a[i].first == day) { q.push(a[i++].first); } for (int j = 0; j < k; j++) { if (q.empty()) { break; } if (day - q.front() > d) { return 0; } q.pop(); } } return 1; }; int lo = 1, hi = n; while (lo <= hi) { int mid = (lo + hi) >> 1; if (check(mid)) { hi = mid - 1; } else { lo = mid + 1; } } cout << hi + 1 << '\n'; queue<int> q; int i = 0; for (int day = 1; day <= n; day++) { while (i < m && a[i].first == day) { q.push(a[i++].second); } for (int j = 0; j < hi + 1; j++) { if (q.empty()) { break; } cout << q.front() + 1 << ' '; q.pop(); } cout << 0 << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...