Submission #1330054

#TimeUsernameProblemLanguageResultExecution timeMemory
1330054AgageldiJob Scheduling (CEOI12_jobs)C++20
10 / 100
106 ms11468 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define N 500005
#define ff first
#define ss second

const int inf = 1e18;

int n, m, t;
pair <int,int> a[N];

int32_t main() {
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n >> m >> t;
    for(int i = 1; i <= t; i++) {
        cin >> a[i].ff;
        a[i].ss = i;
    }
    sort(a + 1, a + t + 1);
    int l = 1, r = 1e15;
    while(l <= r) {
        int mid = (l + r) / 2, cnt = 0, k = 0, ok = 0;
        for(int i = 1; i <= t; i++) {
            k++;
            if(k == mid + 1) {
                cnt++;
                k = 1;
            }
            if(a[i].ff + m < cnt) {
                ok = 1;
                break;
            }
        }
        if(ok || cnt > n) {
            l = mid + 1;
        }
        else {
            r = mid - 1;
        }
    }
    r++;
    cout << r << endl;
    int cnt = 1, k = 0;
    for(int i = 1; i <= t; i++) {
        k++;
        if(k == r + 1) {
            k = 1;
            cnt++;
            cout << "0\n";
        }
        cout << a[i].ss << " ";
    }
    for(int i = cnt; i <= n; i++) {
        cout << "0\n";
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...