Submission #742947

# Submission time Handle Problem Language Result Execution time Memory
742947 2023-05-17T06:45:44 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
15 / 100
32 ms 11072 KB
#include<bits/stdc++.h>

using namespace std;

using ll = long long ;
using pii = pair<ll , ll> ;
using i3 = tuple<ll , ll , ll> ;

const int N = 1e5+5 ;
const int MOD = 1e9+7 ;

int n , d , m ;
pii S[N] ;

vector<int> ans2[N] ;

bool solve(int mid){

    int day = 1 , cnt = 0 ;
    for(int i=1;i<=m;i++){
        if(day <= S[i].first + d){ // do job i
            cnt++ ;
            ans2[day].push_back(S[i].second) ;
        }
        else {
            return false ;
        }
        if(cnt == mid){
            day++;
            cnt = 0 ;
        }
    }

    return day-1 <= n ;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> d >> m ;
    for(int i=1, x;i<=m;i++){
        cin >> x ;
        S[i] = {x , i};
    }

    sort(S+1 , S+m+1) ;

    int l = 1 , r = m , ans ;

    while(l <= r){
        int mid = (l+r)/2 ;

        if(solve(mid)){
            r = mid-1 ;
            ans = mid ;
        }
        else {
            l = mid+1 ;
            for(int i=1;i<=n;i++) ans2[i].clear();
        }
    }

    cout << ans << "\n" ;
    for(int i=1;i<=n;i++){
        for(int x : ans2[i]){
            cout << x << " " ;
        }
        cout << "0\n" ;
    }
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:63:20: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   63 |     cout << ans << "\n" ;
      |                    ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 7556 KB Output isn't correct
2 Incorrect 16 ms 7560 KB Output isn't correct
3 Incorrect 24 ms 8424 KB Output isn't correct
4 Incorrect 16 ms 7556 KB Output isn't correct
5 Incorrect 17 ms 8320 KB Output isn't correct
6 Incorrect 17 ms 8256 KB Output isn't correct
7 Incorrect 32 ms 9060 KB Output isn't correct
8 Incorrect 24 ms 8140 KB Output isn't correct
9 Correct 25 ms 7628 KB Output is correct
10 Correct 25 ms 7544 KB Output is correct
11 Correct 32 ms 11072 KB Output is correct
12 Runtime error 13 ms 8684 KB Execution killed with signal 11
13 Runtime error 13 ms 8544 KB Execution killed with signal 11
14 Runtime error 17 ms 9164 KB Execution killed with signal 11
15 Runtime error 14 ms 8720 KB Execution killed with signal 11
16 Runtime error 22 ms 9392 KB Execution killed with signal 11
17 Runtime error 21 ms 9712 KB Execution killed with signal 11
18 Runtime error 15 ms 8804 KB Execution killed with signal 11
19 Runtime error 16 ms 8596 KB Execution killed with signal 11
20 Runtime error 20 ms 9732 KB Execution killed with signal 11