Submission #970943

# Submission time Handle Problem Language Result Execution time Memory
970943 2024-04-27T14:52:38 Z jadai007 Job Scheduling (CEOI12_jobs) C++14
100 / 100
162 ms 17180 KB
#include<bits/stdc++.h>

using namespace std;

int n, d, m, day[1000100];
vector<int> times[100100];

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> d >> m;
    for(int i = 1; i <= m; ++i){
        cin >> day[i];
        times[day[i]].push_back(i);
    }
    int l = 1, r = 1e9;
    while(l < r){
        int mid = (l + r) >> 1, check = true;
        queue<int> q;
        for(int i = 1; i<=n; ++i){
            int k = mid;
            for(auto x:times[i]) q.push(x);
            while(k-- && !q.empty()) q.pop();
            if(!q.empty() && day[q.front()] + d == i){
                check = false;
                break;
            }
        }
        if(check) r = mid;
        else l = mid+1;
    }
    cout << l << '\n';
    queue<int> q;
    for(int i = 1; i<=n; ++i){
        int k = l;
        for(auto x:times[i]) q.push(x);
        while(k-- && !q.empty()){
            cout << q.front() << ' ';
            q.pop();
        }
        cout << "0\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 18 ms 6096 KB Output is correct
2 Correct 19 ms 6104 KB Output is correct
3 Correct 19 ms 6108 KB Output is correct
4 Correct 19 ms 6040 KB Output is correct
5 Correct 19 ms 6124 KB Output is correct
6 Correct 19 ms 6108 KB Output is correct
7 Correct 19 ms 6264 KB Output is correct
8 Correct 19 ms 6108 KB Output is correct
9 Correct 24 ms 5980 KB Output is correct
10 Correct 26 ms 5968 KB Output is correct
11 Correct 19 ms 5724 KB Output is correct
12 Correct 36 ms 6996 KB Output is correct
13 Correct 55 ms 8920 KB Output is correct
14 Correct 86 ms 10180 KB Output is correct
15 Correct 87 ms 11084 KB Output is correct
16 Correct 125 ms 13240 KB Output is correct
17 Correct 147 ms 15512 KB Output is correct
18 Correct 153 ms 15952 KB Output is correct
19 Correct 162 ms 17180 KB Output is correct
20 Correct 143 ms 15700 KB Output is correct