Submission #1003354

#TimeUsernameProblemLanguageResultExecution timeMemory
1003354AtinaRJob Scheduling (CEOI12_jobs)C++14
55 / 100
264 ms34576 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,d,m;
    cin>>n>>d>>m;
    pair<long long,long long> niza[m];
    for(long long i=0; i<m; i++)
    {
        cin>>niza[i].first;
        niza[i].second=i+1;
    }
    sort(niza,niza+m);
    long long b=0,e=m+1;
    long long res=0;
    while(b<=e)
    {
        long long mid=(b+e)/2;
        long long cnt=0;
        long long day=1;
        long long og=0;
        bool flag=true;
        for(long long i=0; i<m; i++)
        {
            cnt++;
            if(cnt>mid || niza[i].first>day || niza[i].first-niza[og].first>d)
            {
                cnt=1;
                og=i;
                day++;
            }
            if(day-niza[i].first>d || day>n)
            {
                flag=false;
                break;
            }
        }
        if(flag)
        {
            res=mid;
            e=mid-1;
        }
        else b=mid+1;
    }
    cout<<res<<endl;
    long long cnt=0;
    long long day=1;
    long long og=0;
    vector<long long> ress[n+1];
    for(long long i=0; i<m; i++)
    {
        cnt++;
        if(cnt>res || (niza[i].first>day && niza[i].first-niza[og].first>d))
        {
            cnt=1;
            og=i;
            day++;
        }
        ress[day].push_back(niza[i].second);
    }
    for(long long i=1; i<=n; i++)
    {
        for(auto x:ress[i])cout<<x<<" ";
        cout<<0<<endl;
    }
    return 0;
}
/*

8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
#Verdict Execution timeMemoryGrader output
Fetching results...