# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
933093 | agg | Job Scheduling (CEOI12_jobs) | C++17 | 168 ms | 7888 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 <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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |