# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
927314 | VMaksimoski008 | Job Scheduling (CEOI12_jobs) | C++14 | 126 ms | 7760 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;
using pii = pair<int, int>;
int N, D, M, i, L;
vector<int> v, cnt;
bool check(int mid) {
queue<pii> q;
for(i=1; i<=N; i++) {
L = mid;
if(cnt[i]) q.push({ i, cnt[i] });
while(L && !q.empty()) {
if(i - q.front().first > D) return 0;
q.front().second--;
if(q.front().second == 0) q.pop();
L--;
}
}
return 1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
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, ans = 0, mid;
while(l <= r) {
mid = (l + r) / 2;
if(check(mid)) ans = mid, r = mid - 1;
else l = mid + 1;
}
cout << ans << '\n';
for(i=1; i<=N; i++) cout << 0 << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |