답안 #390180

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390180 2021-04-15T14:10:19 Z grobar Job Scheduling (CEOI12_jobs) C++14
0 / 100
175 ms 1112 KB
#include <bits/stdc++.h>

using namespace std;
int n,d,m;
int a[10001];
vector< pair<int,int> >par;
bool works(int x)
{
    int curr=0;
    for(int day=0;day<n;day++)
    {
        for(int j=0;j<x;j++)
        {
            if(curr<m && par[curr].first<=day+1 && par[curr].first>=day+1-d)
            {
                curr++;
            }else
            {
                break;
            }
        }
    }
    if(curr==m)
    {
        return true;
    }else
    {
        return false;
    }
}
int main()
{
    cin>>n>>d>>m;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        par.push_back(make_pair(a[i],i+1));
    }
    sort(par.begin(),par.end());
    for(int i=0;i<m;i++)
    {
        cout<<par[i].first<<" "<<par[i].second<<endl;
    }
    int low=0,high=m,mid=0,ans=0;
    while(low<=high)
    {
        mid=(low+high)/2;
        if(works(mid)==true)
        {
            ans=mid;
            high=mid-1;
        }else
        {
            low=mid+1;
        }
    }
    cout<<ans<<endl;
    int curr=0;
    for(int day=0;day<n;day++)
    {
        for(int j=0;j<ans;j++)
        {
            if(curr<m && par[curr].first<=day+1 && par[curr].first>=day+1-d)
            {
                cout<<par[curr].second<<" ";
                curr++;
            }else
            {
                break;
            }
        }
        cout<<0;
        cout<<endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 588 KB Expected EOLN
2 Incorrect 19 ms 676 KB Expected EOLN
3 Incorrect 20 ms 676 KB Expected EOLN
4 Incorrect 20 ms 676 KB Expected EOLN
5 Incorrect 19 ms 672 KB Expected EOLN
6 Incorrect 19 ms 680 KB Expected EOLN
7 Incorrect 19 ms 588 KB Expected EOLN
8 Incorrect 19 ms 588 KB Expected EOLN
9 Incorrect 162 ms 920 KB Expected EOLN
10 Incorrect 164 ms 832 KB Expected EOLN
11 Incorrect 6 ms 588 KB Expected EOLN
12 Incorrect 7 ms 588 KB Expected EOLN
13 Incorrect 6 ms 588 KB Expected EOLN
14 Incorrect 34 ms 692 KB Expected EOLN
15 Incorrect 6 ms 580 KB Expected EOLN
16 Incorrect 21 ms 588 KB Expected EOLN
17 Incorrect 33 ms 760 KB Expected EOLN
18 Incorrect 20 ms 572 KB Expected EOLN
19 Incorrect 175 ms 1112 KB Expected EOLN
20 Incorrect 39 ms 736 KB Expected EOLN