Submission #698997

#TimeUsernameProblemLanguageResultExecution timeMemory
698997nguyenneheheJob Scheduling (CEOI12_jobs)C++14
0 / 100
16 ms1624 KiB
#include "bits/stdc++.h"
using namespace std;

const int N = 1e5 + 1;

int n, d, m;
pair<int, int> a[N];

bool good(int k) {
    int j = 1;
    for (int i = 1; i <= n; ++i) {
        for (int x = 1; x <= k; ++x) {
            if (a[j].first > i) break;
            if (a[j].first + d < i) return false;

            if (j == m) return true;
            ++j;
        }
    }
    return false;
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    
    cin >> n >> d >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a + 1, a + 1 + m);
    int l = 0, r = m + 1;
    while (r - l > 1) {
        int mid = (l + r) >> 1;
        if (good(mid)) r = mid;
        else l = mid;
    }

    cout << r << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...