Submission #1091092

# Submission time Handle Problem Language Result Execution time Memory
1091092 2024-09-19T18:50:31 Z andro Job Scheduling (CEOI12_jobs) C++17
0 / 100
90 ms 7644 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m, d, n;
    cin >> m >> d >> n;
    vector<int> a(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a.begin() + 1, a.end());
    int l = 1, r = n, ans = - 1;
    vector<int> br(m + 1, 0);
    for(int i = 1; i <= n; i++) {
        br[a[i]] += 1;
    }
    while(l <= r) {
        int mid = (l + r) / 2;
        int p = 1;
        int ok = 1;
        while(p <= m) {
            if(! br[p]) {
                p += 1;
                continue;
            }
            int trebam = br[p] / mid;
            if(br[p] % mid) {
                trebam += 1;
            }
            if(p + trebam > p + d) {
                ok = 0;
                break;
            }
            else {
                p += 1;
            }
        }
        if(ok) {
            r = mid - 1;
            ans = mid;
        }
        else {
            l = mid + 1;
        }
    }
    cout << ans;
}
/*

*/
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1116 KB Output isn't correct
2 Incorrect 5 ms 984 KB Output isn't correct
3 Incorrect 5 ms 1116 KB Output isn't correct
4 Incorrect 5 ms 1116 KB Output isn't correct
5 Incorrect 5 ms 976 KB Output isn't correct
6 Incorrect 5 ms 976 KB Output isn't correct
7 Incorrect 5 ms 980 KB Output isn't correct
8 Incorrect 5 ms 1156 KB Output isn't correct
9 Incorrect 8 ms 1376 KB Output isn't correct
10 Incorrect 8 ms 1372 KB Output isn't correct
11 Incorrect 9 ms 1244 KB Output isn't correct
12 Incorrect 17 ms 1880 KB Output isn't correct
13 Incorrect 26 ms 2648 KB Output isn't correct
14 Incorrect 41 ms 3924 KB Output isn't correct
15 Incorrect 43 ms 4080 KB Output isn't correct
16 Incorrect 60 ms 5684 KB Output isn't correct
17 Incorrect 75 ms 6488 KB Output isn't correct
18 Incorrect 68 ms 6488 KB Output isn't correct
19 Incorrect 90 ms 7644 KB Output isn't correct
20 Incorrect 71 ms 6492 KB Output isn't correct