제출 #1308280

#제출 시각아이디문제언어결과실행 시간메모리
1308280joze_plocnikJob Scheduling (CEOI12_jobs)C++20
60 / 100
102 ms13488 KiB
#include <iostream>
#include <algorithm> 
#include <vector>
#include <queue>

#define vi vector<int>
#define vpii vector<pair<int,int>>
#define oopt cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false);
#define forn(i,n) for(int i = 0; i<n; i++)
#define sz(x) (x).size()

using namespace std;


int main() {
    oopt;
    int n,d,m; cin >> n >> d>>m; 
    vector<vector<int>> vrednosti(n);
    pair<int,int> pntr = {0,0};
    
    forn(i,m){
        int t; cin >> t;
        vrednosti[--t].push_back(i+1);
    }

    int l = 1, r= 1e6;
    while(l<r){
        int rob = (l+r)/2;
        bool vredu = true;
        pntr = {0,0};
        forn(i,n){
            int mesta = rob;
            while(mesta){
                while(pntr.second >= vrednosti[pntr.first].size()){
                    if(i-pntr.first > d) vredu = false;
                    pntr.first++;
                    pntr.second = 0;
                    if(pntr.first > i) break;
                }
                if(pntr.first > i) break;
                pntr.second++; 
                mesta--;
            }
        }
        
        if(vredu){
            r = rob;
        } else {
            l = rob+1;
        }
    }
    cout << l << "\n";
  
    pntr = {0,0};
    int rob = l;
    forn(i,n){
        int mesta = rob;
        while(mesta){
            while(pntr.second >= vrednosti[pntr.first].size()){
                pntr.first++;
                pntr.second = 0;
                if(pntr.first > i) break; // šli smo predaleč
            }
            if(pntr.first > i) break;
            cout << vrednosti[pntr.first][pntr.second] << " "; 
            pntr.second++; 
            mesta--;
        }
        cout << "0\n";
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...