답안 #763732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763732 2023-06-22T17:54:13 Z Petrix Job Scheduling (CEOI12_jobs) C++17
0 / 100
1000 ms 7300 KB
#include <iostream>
#include <algorithm>
using namespace std;

struct vc{
    int a,ind;
}v[1000000];

bool cmp(vc a,vc b){
    if(a.a<b.a)
        return 1;
    else
        return 0;
}

int n,m;

bool verf(int mij){
    int z,i,dr,st,mmij,rasp;
    z=mij-1;i=1;
    while(z<m-1 && i<=n){///printf("a");
        dr=z;rasp=dr;
        st=z-mij+1;
        while(st<dr){

            mmij=(st+dr)/2;
            if(v[mmij].a>i)
                dr=mmij-1;
            else{
                rasp=mmij;
                st=mmij-1;
            }

        }
        z=rasp;
        if(i>v[z].a)
            break;
        i++;
        z=min(z+mij,m-1);
    }
    if(z<m-1 && i<=n)
        return 0;
    else
        return 1;
}

int main()
{
    int st,dr,mij,d,rasp,i,vf,poz,j;
    cin>>n>>d>>m;
    for(i=0;i<m;i++){
        cin>>v[i].a;
        v[i].ind=i+1;
        v[i].a+=d;
    }
    sort(v,v+m,cmp);
    st=1;dr=1000000;rasp=mij=0;
    while(st<dr){
        mij=(st+dr)/2;
        vf=verf(mij);
        if(vf==1){
            rasp=mij;
            dr=mij-1;
        }else{
            st=mij+1;
        }
    }
    cout<<rasp<<"\n";
    poz=0;
    for(i=0;i<n;i++){
        for(j=0;j<rasp && poz<m;j++){
            cout<<v[poz].ind<<" ";
            poz++;
        }
        cout<<"0\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1080 ms 980 KB Time limit exceeded
2 Execution timed out 1077 ms 1020 KB Time limit exceeded
3 Execution timed out 1086 ms 980 KB Time limit exceeded
4 Execution timed out 1083 ms 980 KB Time limit exceeded
5 Execution timed out 1076 ms 1108 KB Time limit exceeded
6 Execution timed out 1077 ms 980 KB Time limit exceeded
7 Execution timed out 1078 ms 1012 KB Time limit exceeded
8 Execution timed out 1070 ms 980 KB Time limit exceeded
9 Execution timed out 1081 ms 1012 KB Time limit exceeded
10 Execution timed out 1083 ms 984 KB Time limit exceeded
11 Execution timed out 1081 ms 956 KB Time limit exceeded
12 Execution timed out 1074 ms 1792 KB Time limit exceeded
13 Execution timed out 1075 ms 2508 KB Time limit exceeded
14 Execution timed out 1071 ms 3408 KB Time limit exceeded
15 Execution timed out 1072 ms 4180 KB Time limit exceeded
16 Execution timed out 1079 ms 4900 KB Time limit exceeded
17 Execution timed out 1078 ms 5752 KB Time limit exceeded
18 Execution timed out 1076 ms 6488 KB Time limit exceeded
19 Execution timed out 1080 ms 7300 KB Time limit exceeded
20 Execution timed out 1083 ms 5768 KB Time limit exceeded