Submission #256279

# Submission time Handle Problem Language Result Execution time Memory
256279 2020-08-02T13:33:27 Z Molukhyyeh Job Scheduling (CEOI12_jobs) C++14
37 / 100
367 ms 23032 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 200001, M = 1e6+100;
int n, d, m;
pair<int,int> v[M];
vector<int> pr[N];

bool ok(int md){
     int av = md, day = 0, cur = 0; 
     for(int i = 0; i<m; ++i){
        cur = day; 
        --av;
        if(!av)av = md, ++day;
        if(cur >= v[i].first+d)return false;
     }
     return true;
} 

int main(){
    scanf("%d%d%d", &n, &d, &m);
    for(int i = 0; i<m; ++i){
    	scanf("%d", &v[i].first);
    	v[i].second = i+1;
    }
    sort(v, v+m);
    int l = 1, r = m, md, an = m;
    while(l <= r){
    	 md = l + r >> 1;
    	 if(ok(md))r = md-1, an = md;
    	 else l = md+1;
    }
    printf("%d\n", an);
    int day = 1, av = an, ls = 0;
    for(int i = 0; i<m; ++i){
       pr[ls].push_back(v[i].second);
       --av; 
       if(!av)av = md, ++day, ++ls; 
    }
    for(int i = 0; i<n; ++i){
       for(auto j: pr[i])printf("%d ", j);
       puts("0");
    }
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:31:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
       md = l + r >> 1;
            ~~^~~
jobs.cpp:23: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:25:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d", &v[i].first);
      ~~~~~^~~~~~~~~~~~~~~~~~~
jobs.cpp:39:8: warning: 'av' may be used uninitialized in this function [-Wmaybe-uninitialized]
        --av; 
        ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 7292 KB Output isn't correct
2 Incorrect 40 ms 7296 KB Output isn't correct
3 Incorrect 34 ms 7160 KB Output isn't correct
4 Incorrect 30 ms 7292 KB Output isn't correct
5 Incorrect 39 ms 7160 KB Output isn't correct
6 Incorrect 32 ms 7160 KB Output isn't correct
7 Incorrect 34 ms 7288 KB Output isn't correct
8 Incorrect 38 ms 7416 KB Output isn't correct
9 Partially correct 41 ms 7416 KB Partially correct
10 Partially correct 41 ms 7420 KB Partially correct
11 Correct 62 ms 7332 KB Output is correct
12 Correct 90 ms 9464 KB Output is correct
13 Partially correct 122 ms 11896 KB Partially correct
14 Correct 182 ms 13944 KB Output is correct
15 Incorrect 197 ms 14840 KB Output isn't correct
16 Correct 257 ms 16888 KB Output is correct
17 Partially correct 319 ms 20984 KB Partially correct
18 Correct 338 ms 21368 KB Output is correct
19 Partially correct 367 ms 23032 KB Partially correct
20 Partially correct 315 ms 20968 KB Partially correct