Submission #556844

#TimeUsernameProblemLanguageResultExecution timeMemory
556844JomnoiJob Scheduling (CEOI12_jobs)C++17
45 / 100
213 ms17164 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_M = 1e6 + 10; int N, D, M; int S[MAX_M], id[MAX_M]; bool solve(int mid) { int days = 1, cnt = mid; for(int i = 1; i <= M; i++) { if(days > S[id[i]] + D) { return false; } cnt--; if(cnt == 0) { cnt = mid; days++; } } return days <= N; } int main() { cin.tie(nullptr)->sync_with_stdio(false); cin >> N >> D >> M; for(int i = 1; i <= M; i++) { cin >> S[i]; id[i] = i; } sort(id + 1, id + M + 1, [&](const int &a, const int &b) { return S[a] < S[b]; }); int l = 1, r = M; while(l < r) { int mid = (l + r) / 2; if(solve(mid) == true) { r = mid; } else { l = mid + 1; } } cout << l << '\n'; for(int i = 1, j = 1; i <= N; i++) { for(int k = 0; j <= M and k < l ; j++, k++) { cout << id[j] << ' '; } cout << "0\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...