제출 #1361941

#제출 시각아이디문제언어결과실행 시간메모리
1361941h.oussamaJob Scheduling (CEOI12_jobs)C++20
90 / 100
61 ms14240 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;//998244353

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int N,M,D;
    cin>>N>>D>>M;
    vector<int>J(N+1);
    vector<vector<int>>P(N+1);
    for (int i = 0; i < M; i++)
    {
        int x;
        cin>>x;
        J[x]++;
        P[x].push_back(i+1);
    }
    int lo=1;int hi=M;
    int mid;
    vector<int>cur;
    int ans=0;
    while (lo<=hi)
    {
        mid = lo+(hi-lo)/2;
        cur.assign(J.begin(),J.end());
        int last=1;
        bool ok=true;
        int val;
        for (int i = 1; i <= N; i++)
        {
            if(last+D<i)ok=false;
            val=mid;
            while (last<=i && val)
            {
                int mo=max(0,val-cur[last]);
                cur[last]=max(0,cur[last]-val);
                val=mo;
                if(cur[last]==0 && last<=i)last++;
            }
        }
        if(last>N && ok){
            ans=mid;
            hi=mid-1;
        }else{
            lo=mid+1;
        }
    }
    cout<<ans;
    queue<int>what;
    for (int i = 1; i <= N; i++)
    {
        cout<<"\n";
        for (auto sd:P[i])
        {
            what.push(sd);
        }
        for (int i = 0; i < ans && !what.empty(); i++)
        {
            cout<<what.front()<<" ";
            what.pop();
        }
        cout<<0;
    }
    
    
    return 0;

}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…