제출 #1000139

#제출 시각아이디문제언어결과실행 시간메모리
1000139codexistentJob Scheduling (CEOI12_jobs)C++14
40 / 100
360 ms17484 KiB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define MAXN 100005
#define MAXM 1000000

int n, d, m, arr[MAXN], res = 0;
pair<int, int> req[MAXM];

int main(){
    cin >> n >> d >> m;
    FOR(i, 1, n) arr[i] = 0;
    FOR(i, 1, m){
        int x; cin >> x;
        arr[x]++;
        req[i - 1] = {x, i};
    }
    sort(req,  req + m - 1);

    multiset<int> s; 
    FOR(i, 1, 1 + d) s.insert(0);

    FOR(i, 1, n){
        res = max(res, *s.rbegin());
        s.erase(s.find(*s.rbegin()));
        s.insert(0);

        FOR(j, 1, arr[i]){
            int k = *s.begin();
            s.erase(s.begin());
            s.insert(k + 1);
        }
    }
    res = max(res, *s.rbegin());

    cout << res << endl;

    int k = -1;
    FOR(i, 1, n){
        int j = 1;
        while(j <= res && (k + 1 < m) && (req[k + 1].first <= i && i <= req[k + 1].first + d)){
            cout << req[k + 1].second << " ";
            j++, k++;
        }

        cout << "0" << endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...