Submission #1082215

#TimeUsernameProblemLanguageResultExecution timeMemory
1082215galaxy_kittyJob Scheduling (CEOI12_jobs)C++17
100 / 100
240 ms17492 KiB
#include <iostream> #include <utility> #include <algorithm> #include <vector> #include <set> using namespace std; int main() { int n, d, m; cin >> n >> d >> m; int day[100000] = {}; vector<int> arr[n]; for (int i = 0; i < m; i++) { int a; cin >> a; day[a - 1]++; arr[a - 1].push_back(i + 1); } int l = 0, r = m, mid = (l + r + 1) / 2; while (l < r) { set<pair<int, int>> q; bool f = true; for (int i = 0; i < n; i++) { if (day[i] != 0) { q.insert({i, day[i]}); } int a = mid; while (a > 0 && q.begin() != q.end()) { int b = min(a, (*q.begin()).second); q.insert({(*q.begin()).first, (*q.begin()).second - b}); q.erase(++q.begin()); a -= b; if ((*q.begin()).second == 0) { q.erase(q.begin()); } } if (q.begin() != q.end() && i - (*q.begin()).first == d) { f = false; break; } } if (f) { r = mid - 1; mid = (l + r + 1) / 2; } else { l = mid; mid = (l + r + 1) / 2; } } mid++; cout << mid << "\n"; set<pair<int, int>> q; for (int i = 0; i < n; i++) { for (auto a : arr[i]) { q.insert({i, a}); } for (int a = 0; (a < mid && q.begin() != q.end()); a++) { cout << (*q.begin()).second << " "; q.erase(q.begin()); } cout << 0 << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...