Submission #677590

#TimeUsernameProblemLanguageResultExecution timeMemory
677590RaedJob Scheduling (CEOI12_jobs)C++14
0 / 100
145 ms6372 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mk make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
ll n,m,a[200100],k;
bool go(ll mid){
    int o=0,d=0;
    for(int i=0;i<m;i++){
        if(d-a[i]>=k)
            return false;
        o++;
        if(o>=mid){
            o=0;
            d++;
        }
    }
    return true;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>k>>m;
    vector<pair<ll,int> >v;
    for(int i=0;i<m;i++){
        cin>>a[i];
        v.pb({a[i],i});
    }
    ll l=0,r=1e9,ans=1e9;
    while(l<=r){
        ll mid=(l+r)/2;
        if(go(mid)){
            r=mid-1;
            ans=mid;
        }
        else{
            l=mid+1;
        }
    }
    cout<<ans<<endl;
    sort(v.begin(),v.end());
    int k=0;
    for(int i=0;i<n;i++){
        int o=0;
        for(int j=k;j<m;j++){
            cout<<v[j].ss+1<<" ";
            o++;
            k++;
            if(o==ans)
                break;
        }
        cout<<0<<endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...