Submission #1134251

#TimeUsernameProblemLanguageResultExecution timeMemory
1134251lopkusJob Scheduling (CEOI12_jobs)C++20
0 / 100
1094 ms28448 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, d, m; cin >> n >> d >> m; vector<int> a(m + 1); for(int i = 1; i <= m; i++) { cin >> a[i]; a[i] = max(a[i], i); } int l = 1, r = m, ans = - 1; while(l <= r) { int mid = (l + r) / 2; set<int> s; int ok = 1; for(int i = 1; i <= m; i++) { if(s.size() < mid) { s.insert(a[i] + 1); } else { if(a[i] >= *s.begin()) { auto it = s.begin(); s.erase(it); s.insert(a[i] + 1); } else { ok = 0; break; } } } if(ok) { r = mid - 1; ans = mid; } else { l = mid + 1; } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...