# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
900207 | VMaksimoski008 | Job Scheduling (CEOI12_jobs) | C++14 | 240 ms | 4336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
int N, D, M;
vector<int> v, cnt;
bool check(int mid) {
int left = mid;
queue<int> q;
for(int i=1; i<=N; i++) {
left = mid;
for(int j=0; j<cnt[i]; j++) q.push(i);
while(left > 0 && !q.empty()) {
int u = q.front();
q.pop();
if(i - u > D) return false;
left--;
}
}
return true;
}
int32_t main() {
cin >> N >> D >> M;
v.resize(M);
cnt.resize(N+1);
for(int &x : v) cin >> x, cnt[x]++;
sort(all(v));
int l=1, r=M;
int ans = 0;
while(l <= r) {
int mid = (l + r) / 2;
if(check(mid)) ans = mid, r = mid - 1;
else l = mid + 1;
}
cout << ans << '\n';
for(int i=1; i<=N; i++) cout << 0 << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |