Submission #763734

# Submission time Handle Problem Language Result Execution time Memory
763734 2023-06-22T17:55:43 Z Petrix Job Scheduling (CEOI12_jobs) C++17
0 / 100
1000 ms 7320 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=m/d+1;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;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 980 KB Time limit exceeded
2 Execution timed out 1088 ms 980 KB Time limit exceeded
3 Execution timed out 1087 ms 1052 KB Time limit exceeded
4 Execution timed out 1083 ms 980 KB Time limit exceeded
5 Execution timed out 1048 ms 980 KB Time limit exceeded
6 Execution timed out 1082 ms 980 KB Time limit exceeded
7 Execution timed out 1077 ms 980 KB Time limit exceeded
8 Execution timed out 1080 ms 1072 KB Time limit exceeded
9 Execution timed out 1080 ms 1064 KB Time limit exceeded
10 Execution timed out 1080 ms 980 KB Time limit exceeded
11 Execution timed out 1076 ms 980 KB Time limit exceeded
12 Execution timed out 1078 ms 1724 KB Time limit exceeded
13 Execution timed out 1076 ms 2608 KB Time limit exceeded
14 Execution timed out 1065 ms 3312 KB Time limit exceeded
15 Execution timed out 1083 ms 4180 KB Time limit exceeded
16 Execution timed out 1082 ms 4940 KB Time limit exceeded
17 Execution timed out 1088 ms 5720 KB Time limit exceeded
18 Execution timed out 1089 ms 6464 KB Time limit exceeded
19 Execution timed out 1085 ms 7320 KB Time limit exceeded
20 Execution timed out 1063 ms 5708 KB Time limit exceeded