Submission #455160

# Submission time Handle Problem Language Result Execution time Memory
455160 2021-08-05T15:16:25 Z shahriarkhan Job Scheduling (CEOI12_jobs) C++14
0 / 100
173 ms 15632 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)/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) ;
    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 15 ms 6212 KB Output isn't correct
2 Incorrect 16 ms 6292 KB Output isn't correct
3 Incorrect 16 ms 6212 KB Output isn't correct
4 Incorrect 16 ms 6316 KB Output isn't correct
5 Incorrect 16 ms 6212 KB Output isn't correct
6 Incorrect 16 ms 6244 KB Output isn't correct
7 Incorrect 16 ms 6212 KB Output isn't correct
8 Incorrect 20 ms 6212 KB Output isn't correct
9 Incorrect 22 ms 6420 KB Unexpected end of file - int32 expected
10 Incorrect 22 ms 6356 KB Unexpected end of file - int32 expected
11 Incorrect 21 ms 6464 KB Unexpected end of file - int32 expected
12 Incorrect 37 ms 7416 KB Unexpected end of file - int32 expected
13 Incorrect 52 ms 9528 KB Unexpected end of file - int32 expected
14 Incorrect 108 ms 10604 KB Unexpected end of file - int32 expected
15 Incorrect 90 ms 10184 KB Unexpected end of file - int32 expected
16 Incorrect 124 ms 11592 KB Unexpected end of file - int32 expected
17 Incorrect 173 ms 15556 KB Unexpected end of file - int32 expected
18 Incorrect 148 ms 13876 KB Unexpected end of file - int32 expected
19 Incorrect 163 ms 13908 KB Unexpected end of file - int32 expected
20 Incorrect 149 ms 15632 KB Unexpected end of file - int32 expected