Submission #919786

# Submission time Handle Problem Language Result Execution time Memory
919786 2024-02-01T16:09:56 Z Ahmed_Kaaniche Job Scheduling (CEOI12_jobs) C++17
0 / 100
126 ms 21148 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;
    for (int i = 0; i < n-d; ++i) {
        for(auto elt :arr[i]){
            cout << elt+1 << ' ';
            cnt++;
            if (cnt%r==0)
                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 15 ms 2260 KB Output isn't correct
2 Incorrect 13 ms 2264 KB Output isn't correct
3 Incorrect 13 ms 2384 KB Output isn't correct
4 Incorrect 14 ms 2260 KB Output isn't correct
5 Incorrect 14 ms 2264 KB Output isn't correct
6 Incorrect 16 ms 2252 KB Output isn't correct
7 Incorrect 14 ms 2260 KB Output isn't correct
8 Incorrect 13 ms 2428 KB Output isn't correct
9 Incorrect 22 ms 5072 KB Unexpected end of file - int32 expected
10 Incorrect 24 ms 4684 KB Unexpected end of file - int32 expected
11 Incorrect 14 ms 2392 KB Output isn't correct
12 Incorrect 27 ms 4352 KB Output isn't correct
13 Incorrect 39 ms 7760 KB Output isn't correct
14 Incorrect 64 ms 10312 KB Output isn't correct
15 Incorrect 71 ms 11600 KB Output isn't correct
16 Incorrect 94 ms 15256 KB Output isn't correct
17 Incorrect 109 ms 18728 KB Output isn't correct
18 Incorrect 101 ms 17956 KB Output isn't correct
19 Incorrect 126 ms 21148 KB Output isn't correct
20 Incorrect 109 ms 18768 KB Output isn't correct