Submission #919792

# Submission time Handle Problem Language Result Execution time Memory
919792 2024-02-01T16:19:53 Z Ahmed_Kaaniche Job Scheduling (CEOI12_jobs) C++17
10 / 100
135 ms 18316 KB
#include <bits/stdc++.h>
using namespace std;




#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define lob lower_bound
#define upb upper_bound
#define bin binary_search
#define endl "\n"
#define tos to_string

ll n,m,d;
vector<vector<ll>>arr;

bool val(ll x){
    int cnt1=0,cnt2=1;
    for (int i = 0; i < n-d; ++i) {
        cnt1=0;
        for(auto elt :arr[i]){
            if(cnt1<x){
                cnt1++;
                continue;
            }
            cnt2++;
        }
        if ((cnt2/x==d&&cnt2%x>0)||cnt2/x>d)
            return 0;
    }
    return 1;
}

int main() {
    //the booster of input and output :
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
//    freopen("perimeter.in","r",stdin);
//    freopen("perimeter.out","w",stdout);
    
    //the body :
    cin>>n>>d>>m;
    arr.resize(n-d);
    for (int i = 0; i < m; ++i) {
        int x;
        cin>> x;
        arr[--x].pb(i);
    }
    
    ll l=0,r=1e9,mid;
    while (l+1<r){
        mid=(l+r)/2;
        if(val(mid)){
            r=mid;
        }
        else{
            l=mid;
        }
    }
    cout << r << endl;
    int cnt=0,j=0;
    for (int i = 0; i < n-d; ++i) {
        for(auto elt :arr[i]){
            cout << elt+1 << ' ';
            cnt++;
            if (cnt%r==0){
                cout << 0 << endl;
                j++;
            }
        }
    }
    
    for (int i = 0; i < n-j; ++i) {
        cout << 0 << endl;
    }
    
    return 0;
}

Compilation message

jobs.cpp: In function 'bool val(long long int)':
jobs.cpp:26:18: warning: unused variable 'elt' [-Wunused-variable]
   26 |         for(auto elt :arr[i]){
      |                  ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 2004 KB Output isn't correct
2 Incorrect 13 ms 2004 KB Output isn't correct
3 Incorrect 14 ms 2008 KB Output isn't correct
4 Incorrect 13 ms 2004 KB Output isn't correct
5 Incorrect 13 ms 2004 KB Output isn't correct
6 Incorrect 13 ms 2008 KB Output isn't correct
7 Incorrect 13 ms 2008 KB Output isn't correct
8 Incorrect 13 ms 2108 KB Output isn't correct
9 Correct 27 ms 4708 KB Output is correct
10 Correct 29 ms 4688 KB Output is correct
11 Incorrect 13 ms 2136 KB Output isn't correct
12 Incorrect 25 ms 3664 KB Output isn't correct
13 Incorrect 37 ms 6732 KB Output isn't correct
14 Incorrect 63 ms 8300 KB Output isn't correct
15 Incorrect 61 ms 9836 KB Output isn't correct
16 Incorrect 94 ms 12716 KB Output isn't correct
17 Incorrect 103 ms 15544 KB Output isn't correct
18 Incorrect 97 ms 15072 KB Output isn't correct
19 Incorrect 135 ms 18316 KB Output isn't correct
20 Incorrect 104 ms 15352 KB Output isn't correct