Submission #455161

# Submission time Handle Problem Language Result Execution time Memory
455161 2021-08-05T15:17:13 Z shahriarkhan Job Scheduling (CEOI12_jobs) C++14
25 / 100
1000 ms 20420 KB
#include<bits/stdc++.h>
using namespace std ;

const int mx = 1e5 + 5 ;

vector<int> pos[mx] ;

vector<int> ans[mx] ;

int siz[mx] ;

int main()
{
    int n , d , m ;
    scanf("%d%d%d",&n,&d,&m) ;
    for(int i = 1 ; i <= m ; ++i)
    {
        int x ;
        scanf("%d",&x) ;
        pos[x].push_back(i) ;
        ++siz[x] ;
    }
    int low = 1 , high = n ;
    while(low<high)
    {
        int mid = (low+high+1)/2 , cnt[mx] = {0} , cur = 1 , bad = 0 ;
        for(int i = 1 ; i <= n ; ++i)
        {
            for(int j = 1 ; j <= siz[i] ; ++j)
            {
                while((cur<i) || (cnt[cur]==mid)) ++cur ;
                if((cur-i)>d)
                {
                    bad = 1 ;
                    break ;
                }
                ++cnt[cur] ;
            }
            if(bad) break ;
        }
        if(!bad) high = mid ;
        else low = mid + 1 ;
    }
    int cnt[mx] = {0} , cur = 1 ;
    for(int i = 1 ; i <= n ; ++i)
    {
        for(int j = 0 ; j < siz[i] ; ++j)
        {
            while((cur<i) || (cnt[cur]==low)) ++cur ;
            ++cnt[cur] ;
            ans[cur].push_back(pos[i][j]) ;
        }
    }
    printf("%d\n",low) ;
    for(int i = 1 ; i <= n ; ++i)
    {
        for(int j : ans[i]) printf("%d ",j) ;
        printf("0\n") ;
    }
    return 0 ;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d%d%d",&n,&d,&m) ;
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
jobs.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%d",&x) ;
      |         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 6844 KB Output isn't correct
2 Incorrect 27 ms 6824 KB Output isn't correct
3 Incorrect 26 ms 6836 KB Output isn't correct
4 Incorrect 26 ms 6820 KB Output isn't correct
5 Incorrect 27 ms 6796 KB Output isn't correct
6 Incorrect 27 ms 6844 KB Output isn't correct
7 Incorrect 26 ms 6916 KB Output isn't correct
8 Incorrect 26 ms 6812 KB Output isn't correct
9 Correct 36 ms 7188 KB Output is correct
10 Execution timed out 1085 ms 5964 KB Time limit exceeded
11 Execution timed out 1088 ms 5952 KB Time limit exceeded
12 Execution timed out 1078 ms 6400 KB Time limit exceeded
13 Execution timed out 1097 ms 7492 KB Time limit exceeded
14 Correct 136 ms 13392 KB Output is correct
15 Execution timed out 1093 ms 8360 KB Time limit exceeded
16 Correct 191 ms 15872 KB Output is correct
17 Correct 225 ms 20344 KB Output is correct
18 Execution timed out 1100 ms 9796 KB Time limit exceeded
19 Execution timed out 1076 ms 9844 KB Time limit exceeded
20 Correct 222 ms 20420 KB Output is correct