제출 #1344157

#제출 시각아이디문제언어결과실행 시간메모리
1344157PakinDioxideJob Scheduling (CEOI12_jobs)C++17
45 / 100
161 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 ans = 1;
    pair <int, int> a[n];
    int id = 1;
    for (auto &[x, y] : a) cin >> x, y = id++;
    sort(a, a+n);
    deque <int> dq;
    for (int i = 0; i < n; i++) {
        dq.emplace_back(a[i].first);
        while (dq.size() && dq.front() + d <= a[i].first) dq.pop_front();
        ans = max(ans, (int) ceil((double) dq.size() / (d+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...