제출 #333381

#제출 시각아이디문제언어결과실행 시간메모리
333381siddarthmJob Scheduling (CEOI12_jobs)C++11
0 / 100
303 ms2156 KiB
#include <iostream>
#include <algorithm>
using namespace std;

pair<int,int> orders[100000];
int n,d,m;
int backlog[100000];

bool works(int x)
{
    //cout << x << endl;
    for(int i=0; i<x; i++)
    {
        backlog[i] = 0;
    }
    for(int i=0; i<m; i++)
    {
        int current = (i/x)+1;
        if(current>(orders[i].first+x))
            return false;
    }
    return true;
}

int main(){
    cin >> n >> d >> m;
    for(int i=0; i<m; i++)
    {
        cin >> orders[i].first;
        orders[i].second = i+1;
    }
    sort(orders, orders+m);
    int a = 1;
    int b = m;
    while(a!=b)
    {
        int mid = (a+b)/2;
        if(works(mid))
            b = mid;
        else
            a = mid+1;
        //cout << endl;
    }
    cout << a << endl;
    int counter = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<a; j++)
        {
            if(counter==m)
                continue;
            cout << orders[counter].second << " ";
            counter++;
        }
        cout << 0 << endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...