제출 #954474

#제출 시각아이디문제언어결과실행 시간메모리
954474davieduJob Scheduling (CEOI12_jobs)C++17
55 / 100
189 ms17124 KiB
#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long

struct P{
    ll x, y;
};

void dbg_out() { cerr << endl; }
template <typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }



signed main(){
    fastio;
    int n, d, m;
    cin >> n >> d >> m;
    vector<pair<int, int>> arr (m);
    for (int i=1, x; i<=m; i++){
        cin >> x;
        arr[i-1] = {x, i};
    }
    sort(all(arr));

    int pcs=1;
    for (int i=0; i<m; i++){
        while ((i+pcs)/pcs > arr[i].first+d) pcs++;
    }

    cout << pcs << '\n';

    int j=0;
    for (int i=0; i<n; i++){
        for (int k=0; k<pcs && j<m; k++, j++){
            cout << arr[j].second << ' ';
        }
        cout << 0 << '\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...