Submission #260327

# Submission time Handle Problem Language Result Execution time Memory
260327 2020-08-10T05:37:19 Z georgerapeanu Job Scheduling (CEOI12_jobs) C++11
100 / 100
371 ms 17360 KB
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int m,n,d;
vector<pair<int,int>> request;

bool ok(int cnt,bool afis){
    if(afis){
        printf("%d\n",cnt);
    }

    int fst = 0;

    for(int i = 1;i <= n;i++){
        if(fst < (int)request.size() && i - request[fst].first > d){
            return false;
        }
        int tmp = cnt;
        while(fst < (int)request.size() && request[fst].first <= i && tmp > 0){
            if(afis){
                printf("%d ",request[fst].second);
            }
            tmp--;
            fst++;
        }
        if(afis){
            printf("0\n");
        }
    }

    return true;

}

int main(){
    
    scanf("%d %d %d",&n,&d,&m);


    for(int i = 1;i <= m;i++){
        int day;
        scanf("%d",&day);
        request.push_back({day,i});
    }

    sort(request.begin(),request.end());

    int st = 0,dr = m + 1;

    while(dr - st > 1){
        int mid = (st + dr) / 2;

        if(ok(mid,false)){
            dr = mid;
        }
        else{
            st = mid;
        }
    }

    ok(dr,true);
    
    return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&n,&d,&m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
jobs.cpp:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&day);
         ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2156 KB Output is correct
2 Correct 28 ms 2156 KB Output is correct
3 Correct 29 ms 2156 KB Output is correct
4 Correct 28 ms 2164 KB Output is correct
5 Correct 30 ms 2164 KB Output is correct
6 Correct 30 ms 2164 KB Output is correct
7 Correct 33 ms 2156 KB Output is correct
8 Correct 28 ms 2156 KB Output is correct
9 Correct 42 ms 2280 KB Output is correct
10 Correct 43 ms 2284 KB Output is correct
11 Correct 38 ms 2156 KB Output is correct
12 Correct 80 ms 4028 KB Output is correct
13 Correct 122 ms 5968 KB Output is correct
14 Correct 166 ms 8156 KB Output is correct
15 Correct 197 ms 9692 KB Output is correct
16 Correct 252 ms 12116 KB Output is correct
17 Correct 297 ms 14036 KB Output is correct
18 Correct 325 ms 15480 KB Output is correct
19 Correct 371 ms 17360 KB Output is correct
20 Correct 298 ms 14032 KB Output is correct