# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
416390 | shubham20_03 | Job Scheduling (CEOI12_jobs) | C++17 | 150 ms | 10820 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>
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
#define deb1(x) cout << #x << "=" << x << endl;
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl;
int N, D, M;
int a[1000300];
bool ok(int m) {
int cm = 0, cd = 1;
for (int i = 1; i <= M; i++) {
if (cm < m) {
if (a[i] > cd)
cm = 1, cd = a[i];
else {
cm++;
if (cd - a[i] > D)
return 0;
}
}
else {
cm = 1, cd++;
if (cd - a[i] > D)
return 0;
}
}
return 1;
}
signed main() {
FAST;
cin >> N >> D >> M;
for (int i = 1; i <= M; i++)
cin >> a[i];
sort(a + 1, a + 1 + M);
int l = 1, r = M, ans = M;
while (l <= r) {
int m = l + (r - l) / 2;
if (ok(m)) ans = m, r = m - 1;
else l = m + 1;
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |