Submission #973191

# Submission time Handle Problem Language Result Execution time Memory
973191 2024-05-01T15:46:49 Z njoop Job Scheduling (CEOI12_jobs) C++17
0 / 100
127 ms 7976 KB
#include <bits/stdc++.h>

using namespace std;

int n, d, m, in, l=0, r=1e9, mid;
vector<int> t[100010];

bool solve(int num) {
    queue<int> q;
    for(int i=1; i<=n; i++) {
        for(int j: t[i]) q.push(i);
        for(int j=1; j<=num && q.size(); j++) q.pop();
        if(q.size() && i-q.front() > d) {
            return 0;
        }
    }
    return 1;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> d >> m;
    for(int i=1; i<=m; i++) {
        cin >> in;
        t[in].push_back(i);
    }
    while(l < r) {
        mid = (l+r)>>1;
        if(solve(mid)) {
            r = mid;
        } else {
            l = mid+1;
        }
    }
    cout << l << "\n";
    return 0;
    queue<int> q;
    for(int i=1; i<=n; i++) {
        for(int j: t[i]) q.push(j);
        for(int j=1; j<=l && q.size(); j++) {
            cout << q.front() << " ";
            q.pop();
        }
        cout << "0\n";
    }
    return 0;
}

Compilation message

jobs.cpp: In function 'bool solve(int)':
jobs.cpp:11:17: warning: unused variable 'j' [-Wunused-variable]
   11 |         for(int j: t[i]) q.push(i);
      |                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 3544 KB Output isn't correct
2 Incorrect 15 ms 3548 KB Output isn't correct
3 Incorrect 16 ms 3548 KB Output isn't correct
4 Incorrect 17 ms 3548 KB Output isn't correct
5 Incorrect 16 ms 3548 KB Output isn't correct
6 Incorrect 16 ms 3548 KB Output isn't correct
7 Incorrect 16 ms 3548 KB Output isn't correct
8 Incorrect 21 ms 3548 KB Output isn't correct
9 Incorrect 23 ms 3420 KB Output isn't correct
10 Incorrect 23 ms 3420 KB Output isn't correct
11 Incorrect 16 ms 3400 KB Unexpected end of file - int32 expected
12 Incorrect 30 ms 3676 KB Unexpected end of file - int32 expected
13 Incorrect 44 ms 4952 KB Output isn't correct
14 Incorrect 68 ms 5460 KB Unexpected end of file - int32 expected
15 Incorrect 75 ms 5840 KB Output isn't correct
16 Incorrect 101 ms 6540 KB Unexpected end of file - int32 expected
17 Incorrect 117 ms 7956 KB Output isn't correct
18 Incorrect 108 ms 7288 KB Output isn't correct
19 Incorrect 127 ms 7248 KB Output isn't correct
20 Incorrect 116 ms 7976 KB Output isn't correct