제출 #699001

#제출 시각아이디문제언어결과실행 시간메모리
699001nguyenneheheJob Scheduling (CEOI12_jobs)C++14
55 / 100
28 ms4756 KiB
#include "bits/stdc++.h" using namespace std; const int N = 1e5 + 1; int n, d, m; pair<int, int> a[N]; vector<int> ans[N]; bool good(int k) { int j = 1; for (int i = 1; i <= n; ++i) { for (int x = 1; x <= k; ++x) { if (a[j].first > i) break; if (a[j].first + d < i) return false; if (j == m) return true; ++j; } } return false; } int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> d >> m; for (int i = 1; i <= m; ++i) { cin >> a[i].first; a[i].second = i; } sort(a + 1, a + 1 + m); int l = 0, r = m + 1; while (r - l > 1) { int mid = (l + r) >> 1; if (good(mid)) r = mid; else l = mid; } cout << r << '\n'; for (int i = 1, j = 1; i <= n; ++i) { for (int x = 1; x <= r && j <= m; ++x, ++j) { if (a[j].first > i) break; ans[i].push_back(a[j].second); } for (int k: ans[i]) cout << k << ' '; cout << "0\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...