Submission #507565

#TimeUsernameProblemLanguageResultExecution timeMemory
507565Christopher_Job Scheduling (CEOI12_jobs)C++17
90 / 100
244 ms13756 KiB
/** * author: lani * created: 12.01.2022 20:57:54 **/ #include <bits/stdc++.h> using namespace std; #ifdef DEBUG #include "debug.hpp" #else #define dbg(...) void(37) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); int n, d, m; cin >> n >> d >> m; vector<pair<int,int>> a(m); for (int i = 0; i < m; ++i) { cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end()); auto Check = [&](int k) { int day = 1, work = 0; for (int i = 0; i < m; ++i) { if (a[i].first > day) { day = a[i].first; ++work; } else if (a[i].first + d < day) { return false; } else { ++work; } if (work >= k) { work = 0; ++day; } } return true; }; int ans = (int) 1e7; int low = 0, high = (int) 1e7; while (low <= high) { int mid = (low + high) >> 1; if (Check(mid)) { high = mid - 1; ans = mid; } else { low = mid + 1; } } cout << ans << '\n'; dbg(); int work = 0; for (int i = 0; i < n; ++i) { int cnt = 0; while (work < m && cnt < ans) { cout << a[work].second + 1 << ' '; ++work; ++cnt; } cout << "0\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...