제출 #1344168

#제출 시각아이디문제언어결과실행 시간메모리
1344168PakinDioxideJob Scheduling (CEOI12_jobs)C++17
40 / 100
171 ms14132 KiB
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n, d, m; cin >> m >> d >> n;
    pair <int, int> a[n];
    int id = 1;
    for (auto &[x, y] : a) cin >> x, y = id++;
    sort(a, a+n);
    int cnt[m+1]; memset(cnt, 0, sizeof(cnt));
    multiset <pair <int, int>> ms;
    int L = 1, R = 0;
    for (auto &[x, y] : a) {
        while (R < x+d && R < m) {
            R++;
            ms.emplace(0, R);
        }
        while (L < x) {
            ms.erase(ms.find(make_pair(cnt[L], L)));
            L++;
        }
        auto [c, id] = *ms.begin();
        ms.erase(ms.begin());
        cnt[id]++;
        ms.emplace(cnt[id], id);
    }
    int x = 0, it = 0, c = 0;
    for (int i = 1; i <= m; i++) x = max(x, cnt[i]);
    cout << x << '\n';
    while (it < n) {
        ++c;
        for (int i = 0; i < x; i++) {
            if (a[it].first > c) break;
            cout << a[it].second << ' ';
            it++;
        }
        cout << 0 << '\n';
    }
    while (c < m) cout << 0 << '\n', c++;
}

#Verdict Execution timeMemoryGrader output
Fetching results...