Submission #263410

# Submission time Handle Problem Language Result Execution time Memory
263410 2020-08-13T16:43:30 Z DS007 Job Scheduling (CEOI12_jobs) C++14
0 / 100
68 ms 768 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5, M = 1e6;
int a[N], cpy[N], n, d, m;

bool check(int mid) {
    for (int i = 1; i <= n; i++)
        cpy[i] = a[i];

    for (int i = 1, last = 1; i <= n; i++) {
        int left = mid;
        while (left && last <= i) {
            if (left >= cpy[last])
                left -= cpy[last++];
            else
                cpy[last] -= left, left = 0;
        }

        if (last <= n + 1)
            exit(0);
        if (i - last > d)
            return false;
    }

    return true;
}

int solveTestCase() {
    cin >> n >> d >> m;
    for (int i = 0; i < m; i++) {
        int temp;
        cin >> temp;
        if (temp >= N)
            exit(0);
        a[temp]++;
    }

    int l = 1, h = M, ans = M;
    while (l <= h) {
        //cerr << l << " " << h << "\n";
        int mid = (l + h) / 2;
        if (check(mid))
            ans = mid, h = mid - 1;
        else
            l = mid + 1;
    }

    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    //cin >> t;
    while (t--)
        solveTestCase();
}


Compilation message

jobs.cpp: In function 'int solveTestCase()':
jobs.cpp:49:13: warning: control reaches end of non-void function [-Wreturn-type]
   49 |     cout << ans;
      |             ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 384 KB Unexpected end of file - int32 expected
2 Incorrect 7 ms 384 KB Unexpected end of file - int32 expected
3 Incorrect 9 ms 384 KB Unexpected end of file - int32 expected
4 Incorrect 7 ms 384 KB Unexpected end of file - int32 expected
5 Incorrect 7 ms 384 KB Unexpected end of file - int32 expected
6 Incorrect 7 ms 384 KB Unexpected end of file - int32 expected
7 Incorrect 7 ms 384 KB Unexpected end of file - int32 expected
8 Incorrect 7 ms 384 KB Unexpected end of file - int32 expected
9 Incorrect 7 ms 768 KB Unexpected end of file - int32 expected
10 Incorrect 8 ms 768 KB Unexpected end of file - int32 expected
11 Incorrect 11 ms 384 KB Unexpected end of file - int32 expected
12 Incorrect 16 ms 512 KB Unexpected end of file - int32 expected
13 Incorrect 23 ms 384 KB Unexpected end of file - int32 expected
14 Incorrect 33 ms 384 KB Unexpected end of file - int32 expected
15 Incorrect 38 ms 384 KB Unexpected end of file - int32 expected
16 Incorrect 49 ms 384 KB Unexpected end of file - int32 expected
17 Incorrect 68 ms 384 KB Unexpected end of file - int32 expected
18 Incorrect 62 ms 384 KB Unexpected end of file - int32 expected
19 Incorrect 68 ms 760 KB Unexpected end of file - int32 expected
20 Incorrect 58 ms 384 KB Unexpected end of file - int32 expected