Submission #1156877

#TimeUsernameProblemLanguageResultExecution timeMemory
1156877goulthenJob Scheduling (CEOI12_jobs)C++20
55 / 100
165 ms21852 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define dl long double
#define rep(i,a,b) for (auto i = a; i <= b; ++i)
#define per(i,a,b) for (auto i = a; i >= b; --i)
#define pii pair<int,int>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
const int MAXN = 1e5 + 10;
int a[MAXN], pfx[MAXN];

void solve() {
    int n,m,d;
    cin >> n >> d >> m;
    vector<pii> t;
    rep(i,1,m) {
        int x;
        cin >> x;
        a[x]++;
        t.pb({x,i});
    }
    rep(i,1,n) pfx[i] = pfx[i-1] + a[i];
    sort(all(t));
    int l = 1, r = m, ans = 0;
    while (l <= r) {
        int mid = (l+r)/2;
        bool ok = true;
        rep(i,1,n) {
            ok &= pfx[max(i-d,0LL)] <= mid*i;
        }

        if (ok) {
            ans = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    cout << ans << '\n';
    int i = 0;
    rep(cur,1,n) {
        rep(j,1,ans) {
            if (i == m  || t[i].fi > cur) break;
            cout <<t[i].se << ' ';
            i++;
        }
        cout << "0\n";
    }
}

int32_t main() {
	ios_base::sync_with_stdio(0);cin.tie(nullptr);
    int tt = 1;
    //cin >> tt;
    while (tt--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...