# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
900208 | VMaksimoski008 | Job Scheduling (CEOI12_jobs) | C++14 | 125 ms | 4360 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;
vector<int> v, cnt;
bool check(int mid) {
int left = mid;
queue<pii> q;
for(int i=1; i<=N; i++) {
left = mid;
if(cnt[i]) q.push({ i, cnt[i] });
while(left > 0 && !q.empty()) {
if(i - q.front().first > D) return false;
q.front().second--;
if(q.front().second == 0) q.pop();
left--;
}
}
return true;
}
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;
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... |