제출 #71483

#제출 시각아이디문제언어결과실행 시간메모리
71483MathStudent2002Job Scheduling (CEOI12_jobs)C++14
5 / 100
474 ms33792 KiB
//wait darn

#include<bits/stdc++.h>

using namespace std;

#define MAXM 1000005
#define x first 
#define y second

int M, N, D;

pair<int,int> job[MAXM];

void read()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    cin >> N >> D >> M;
    for(int i = 0; i < M; i++)
    {
        cin >> job[i].x;
        job[i].x += D;
        job[i].y = i+1;
    }
    
    sort(job,job+M);
}

bool test(long long mech)
{
    long long cur = 0;
    int d = 0;
    
    if(mech < (M+N)/N)
    {
        if(mech*N < M)
            return false;
    }
    
    for(int i = 0; i < M;i++)
    {
        if(job[i].x < ((i/D)+1))
            return false;
    }
    return true;
}

void print(long long mech)
{
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout << mech << endl;
    int d = 0;
    for(int i = 0; i < M;i++)
    {
        cout << job[i].y << " ";
        
        if((i+1)%mech == 0)
        {
            cout << 0 << endl;
            d++;
        }
    }
    
    if(M%mech != 0)
        cout << 0 << endl;
    
    for(; d < N; d++)
        cout << 0 << endl;
}

int solve()
{
    int lo = 1, hi = M, mi;
    while(hi - lo > 1)
    {
        mi = (lo+hi)/2;
        if(test(mi))
            hi = mi;
        else
            lo = mi;
    }
    if(test(lo))
        return lo;
    return hi;
}

int main()
{
    read();
    print(solve());
}

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'bool test(long long int)':
jobs.cpp:32:15: warning: unused variable 'cur' [-Wunused-variable]
     long long cur = 0;
               ^~~
jobs.cpp:33:9: warning: unused variable 'd' [-Wunused-variable]
     int d = 0;
         ^
#Verdict Execution timeMemoryGrader output
Fetching results...