Submission #933093

#TimeUsernameProblemLanguageResultExecution timeMemory
933093aggJob Scheduling (CEOI12_jobs)C++17
100 / 100
168 ms7888 KiB
#include <stdio.h> #include <iostream> #include <deque> using namespace std; typedef long long ll; int main() { int N, M, D; int cnt[1000000]; cin >> N >> D >> M; for (int i = 0; i < M; i++) { int x; cin >> x; cnt[x]++; // budget counter } int l = 1, r = M, ans = 0; while (l <= r) { // bin search int mid = (l + r) >> 1; deque<int> dq; for (int i = 1; i <= N; i++) { if (dq.size() && dq.front() < i) break; for (int j = 0; j < cnt[i]; j++) // put in the jobs dq.push_back(i + D); for (int j = 0; j < mid; j++) { if (dq.empty()) break; dq.pop_front(); // remove allocated items up to mid } } if (dq.empty()) { // if no options then change downward r = mid - 1; ans = mid; } else { // go upward l = mid + 1; } } cout << ans << '\n'; for (int i = 0; i < N; i++) cout << 0 << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...