Submission #1004387

# Submission time Handle Problem Language Result Execution time Memory
1004387 2024-06-21T08:26:29 Z u_suck_o Job Scheduling (CEOI12_jobs) C++17
0 / 100
145 ms 11092 KB
#include <iostream>
#include <vector>
#include <queue>
#define MAXN 100005

using namespace std;

int n, d, m;
vector<int> tasks[MAXN];

int main() {
    cin >> n >> d >> m;
    for (int i = 1; i <= m; i++) {
        int x; cin >> x;
        tasks[x].push_back(i);
    }
    //binary search on answer
    int l = 1, r = m;
    while (l < r) {
        int mid = (l+r)/2;
        queue<pair<int, int>> q;
        bool valid = true;
        for (int i = 1; i <= n; i++) {
            for (int j : tasks[i])
                q.push({j, i});
            for (int j = 1; j <= mid; j++) {
                if (!q.empty()) {
                    auto p = q.front(); q.pop();
                    if (i - p.second > d) {
                        valid = false;
                        break;
                    }
                } else
                    break;
            }
            if (!valid)
                break;
        }
        if (!q.empty())
            valid = false;
        if (valid)
            r = mid;
        else
            l = mid+1;
    }
    
    cout << r << "\n";
    /*//make assignments
    queue<pair<int, int>> q;
    vector<int> v[n];
    for (int i = 1; i <= n; i++) {
        for (int j : tasks[i])
            q.push({j, i});
        for (int j = 1; j <= r; j++) {
            if (!q.empty()) {
                v[i].push_back(q.front().first);
                q.pop();
            }
            else
                break;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j : v[i])
            cout << j << " ";
        cout << "0\n";
    }*/
}
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 4280 KB Unexpected end of file - int32 expected
2 Incorrect 17 ms 4348 KB Unexpected end of file - int32 expected
3 Incorrect 19 ms 4440 KB Unexpected end of file - int32 expected
4 Incorrect 17 ms 4308 KB Unexpected end of file - int32 expected
5 Incorrect 16 ms 4336 KB Unexpected end of file - int32 expected
6 Incorrect 15 ms 4344 KB Unexpected end of file - int32 expected
7 Incorrect 15 ms 4360 KB Unexpected end of file - int32 expected
8 Incorrect 18 ms 4340 KB Unexpected end of file - int32 expected
9 Incorrect 17 ms 3488 KB Unexpected end of file - int32 expected
10 Incorrect 16 ms 3676 KB Unexpected end of file - int32 expected
11 Incorrect 16 ms 3676 KB Unexpected end of file - int32 expected
12 Incorrect 32 ms 4464 KB Unexpected end of file - int32 expected
13 Incorrect 44 ms 5972 KB Unexpected end of file - int32 expected
14 Incorrect 69 ms 7504 KB Unexpected end of file - int32 expected
15 Incorrect 79 ms 7652 KB Unexpected end of file - int32 expected
16 Incorrect 103 ms 9556 KB Unexpected end of file - int32 expected
17 Incorrect 122 ms 11080 KB Unexpected end of file - int32 expected
18 Incorrect 118 ms 10068 KB Unexpected end of file - int32 expected
19 Incorrect 145 ms 10712 KB Unexpected end of file - int32 expected
20 Incorrect 129 ms 11092 KB Unexpected end of file - int32 expected