Submission #392783

# Submission time Handle Problem Language Result Execution time Memory
392783 2021-04-21T16:32:33 Z nicolaalexandra Job Scheduling (CEOI12_jobs) C++14
40 / 100
506 ms 20164 KB
#include <bits/stdc++.h>
#define DIM 1000010
#define DIMN 100010
using namespace std;

priority_queue <int,vector<int>,greater<int> > h;
pair <int,int> v[DIM];
vector <int> ans[DIMN];
int n,d,m,i;

int main (){

    //ifstream cin ("date.in");
    //ofstream cout ("date.out");

    cin>>m>>d>>n;
    for (i=1;i<=n;i++){
        cin>>v[i].first;
        v[i].second = i;
    }

    sort (v+1,v+n+1);

    h.push(1);
    for (i=1;i<=n;i++){
        int day = h.top();

        if (day > v[i].first + d){
            /// mai adaug o masina
            h.push(v[i].first+1);
            ans[v[i].first].push_back(v[i].second);
        } else {
            h.pop();
            ans[max(day,v[i].first)].push_back(v[i].second);
            h.push(max(day+1,v[i].first+1));
        }

    }

    cout<<h.size()<<"\n";

    for (i=1;i<=m;i++){
        for (auto it : ans[i])
            cout<<it<<" ";
        cout<<"0\n";
    }



    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 42 ms 4820 KB Output is correct
2 Correct 41 ms 4864 KB Output is correct
3 Correct 41 ms 4860 KB Output is correct
4 Correct 41 ms 4816 KB Output is correct
5 Correct 41 ms 4804 KB Output is correct
6 Correct 50 ms 4804 KB Output is correct
7 Correct 41 ms 4828 KB Output is correct
8 Correct 41 ms 4812 KB Output is correct
9 Incorrect 54 ms 4852 KB Output isn't correct
10 Incorrect 55 ms 4816 KB Output isn't correct
11 Incorrect 53 ms 4592 KB Output isn't correct
12 Incorrect 106 ms 6556 KB Output isn't correct
13 Incorrect 156 ms 9156 KB Output isn't correct
14 Incorrect 222 ms 11036 KB Output isn't correct
15 Incorrect 262 ms 12860 KB Output isn't correct
16 Incorrect 327 ms 14232 KB Output isn't correct
17 Incorrect 382 ms 18092 KB Output isn't correct
18 Incorrect 431 ms 18684 KB Output isn't correct
19 Incorrect 506 ms 20164 KB Output isn't correct
20 Incorrect 385 ms 18016 KB Output isn't correct