제출 #1135318

#제출 시각아이디문제언어결과실행 시간메모리
1135318MunkhturErdenebatJob Scheduling (CEOI12_jobs)C++20
100 / 100
311 ms20896 KiB
#include<bits/stdc++.h>
#include<string.h>
#include <algorithm>
#include <stdlib.h>
 #define ll long long
using namespace std;
    ll a,b,c,d,e,f,m,i,j,n,h,g,l,r,ka,p,q[200005],t[200005];
    map<ll,ll> maa,mii,mee;
    vector<ll> vas[25],vis,vii;
    pair<ll,ll> k[1000006];
int main(){
    cin>>a>>b>>c;
    for(i=0 ; i<c;  i++){
        cin>>k[i].first;
        k[i].second=i+1;
    }
    sort(k,k+c);
    l=1;
    r=c;
    while(l<r){
        m=(l+r-1)/2;
        g=0;
        h=0;
        ka=1;
        for(i=0 ; i<c ; i++){
            if(k[i].first>ka){
                h=0;
                ka=k[i].first;
                continue;
            }
             if(k[i].first+b<ka){
                g=1;
                break;
            }
            if(k[i].first<=ka && k[i].first+b>=ka){
                h++;
            }
            if(h==m){
                h=0;
                ka++;
            }
           
        }
        
        if(g==1 || ka>a+1){
            l=m+1;
        }
        else{
            r=m;
        }
    }
    cout<<l<<endl;
    h=0;
    ka=1;
    g=0;
    for(i=0 ; i<c ; i++){
        if(k[i].first>ka){
            h=0;
            ka++;
            cout<<0<<endl;
            continue;
        }
        if(k[i].first<=ka && k[i].first+b>=ka){
            h++;
            cout<<k[i].second<<" ";
        }
        if(h==l){
            h=0;
            cout<<0<<endl;
            ka++;
        }
    }
    a-=ka;
    a++;
    while(a--){
        cout<<0<<endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...