Submission #923034

# Submission time Handle Problem Language Result Execution time Memory
923034 2024-02-06T13:06:46 Z MegatronRobo Job Scheduling (CEOI12_jobs) C++17
10 / 100
259 ms 27280 KB
#include "bits/stdc++.h"
using namespace std;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    int N, D, M;
    cin>>N>>D>>M;
    vector<int> req_counter(N+1);
    vector<vector<int>> req_atDay(N+1);
    for(int i=0;i<M;i++){
        int a;
        cin>>a;
        req_counter[a]++;
        req_atDay[a].push_back(i+1);
    }
    int lo=1, hi=M+1;
    while(lo<hi){
        int mid = lo+(hi-lo)/2; // no. of machines
        vector<int> temp=req_counter;
        for(int i=1;i<N;i++){
            temp[i]=max(temp[i]-mid, 0);
            temp[i+1]+=temp[i];
        }
        if(temp[N]<=mid){
            // then possible
            hi=mid;
        }else{
            lo=mid+1;
        }
    }
    // we got our ans=lo
    cout<<lo<<endl;
    // need to show process
    vector<vector<int>> reschedule;
    reschedule.push_back({});
    int curr_count=0;
    for(int i=1;i<req_atDay.size();i++){
        for(int j=0;j<req_atDay[i].size();j++){
            if((curr_count+1)%lo==0){
                curr_count=0;
                reschedule.back().push_back(req_atDay[i][j]);
                reschedule.push_back({});
            }else{
                curr_count++;
                reschedule.back().push_back(req_atDay[i][j]);
            }
        }
    }
    if(reschedule.back()==vector<int>()){
        reschedule.pop_back();
    }
    for(int i=0;i<N;i++){
        if(i>=reschedule.size()){
            goto other;
        }
        for(int j=0;j<lo;j++){
            cout<<reschedule[i][j]<<" ";
        }
        other:;
        cout<<0<<endl;
    }
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=1;i<req_atDay.size();i++){
      |                 ~^~~~~~~~~~~~~~~~~
jobs.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int j=0;j<req_atDay[i].size();j++){
      |                     ~^~~~~~~~~~~~~~~~~~~~
jobs.cpp:53:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         if(i>=reschedule.size()){
      |            ~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 3024 KB Output isn't correct
2 Incorrect 24 ms 2988 KB Output isn't correct
3 Incorrect 26 ms 2848 KB Output isn't correct
4 Incorrect 26 ms 2868 KB Output isn't correct
5 Incorrect 23 ms 3016 KB Output isn't correct
6 Incorrect 28 ms 2852 KB Output isn't correct
7 Incorrect 28 ms 3012 KB Output isn't correct
8 Incorrect 30 ms 2996 KB Output isn't correct
9 Incorrect 155 ms 10268 KB Output isn't correct
10 Incorrect 140 ms 10176 KB Output isn't correct
11 Incorrect 15 ms 2352 KB Expected EOLN
12 Correct 28 ms 4556 KB Output is correct
13 Incorrect 46 ms 7880 KB Expected EOLN
14 Correct 93 ms 10856 KB Output is correct
15 Incorrect 60 ms 10436 KB Expected EOLN
16 Incorrect 107 ms 14088 KB Integer 32219728 violates the range [0, 600000]
17 Incorrect 113 ms 19156 KB Integer 15687968 violates the range [0, 700000]
18 Incorrect 109 ms 18700 KB Output isn't correct
19 Incorrect 259 ms 27280 KB Output isn't correct
20 Incorrect 116 ms 19204 KB Integer 14729504 violates the range [0, 700000]