제출 #1344189

#제출 시각아이디문제언어결과실행 시간메모리
1344189PakinDioxideJob Scheduling (CEOI12_jobs)C++17
64 / 100
166 ms13876 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;
    int L = 1, R = n, ans = -1;
    pair <int, int> a[n];
    int id = 1;
    for (auto &[x, y] : a) cin >> x, y = id++;
    sort(a, a+n);
    while (L <= R) {
        int x = L + (R-L)/2, ok = 1;
        int it = 0, c = 0;
        while (it < n) {
            ++c;
            if (c > m) { ok = 0; break; }
            for (int i = 0; i < x; i++) {
                if (it >= n || a[it].first > c) break;
                if (a[it].first + d < c) { ok = 0; break; }
                it++;
            }
            if (ok == 0) break;
        }
        if (ok) ans = x, R = x-1;
        else L = x+1;
    }
    assert(ans != -1);
    cout << ans << '\n';
    int x = ans, it = 0, c = 0;
    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...