제출 #1168322

#제출 시각아이디문제언어결과실행 시간메모리
1168322ffeyyaeJob Scheduling (CEOI12_jobs)C++20
0 / 100
82 ms13380 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int n, m, d;
vector<int> keep[N];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> d >> m;
    for( int i=1;i<=m;i++ )
    {
        int a; cin >> a;
        keep[a].push_back( i );
    }
    int l = 0, r = n-d;
    while( l<r )
    {
        int mid = (l+r)/2;
        int temp = 0, cnt = 1;
        for( int i=1;i<=n-d;i++ )
        {
            for( auto x : keep[i] )
            {
                if( temp+1 > mid )
                {
                    temp = 0;
                    cnt++;
                }
                temp++;
                if( cnt > i+d )
                {
                    cnt = n;
                    break;
                }
            }
            if( cnt > i+d ) break;
        }
        if( cnt > n-d ) l = mid+1;
        else r = mid;
    }
    cout << l << "\n";
    int temp = 1;
    for( int i=1;i<=n-d;i++ )
    {
        for( int x : keep[i] )
        {
            cout << x << " ";
            if( temp+1 > l )
            {
                temp = 1;
                cout << "0\n";
            } 
            else temp++;
        }
    }
    for( int i=0;i<d;i++ ) cout << 0 << "\n";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...