제출 #923034

#제출 시각아이디문제언어결과실행 시간메모리
923034MegatronRoboJob Scheduling (CEOI12_jobs)C++17
10 / 100
259 ms27280 KiB
#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;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...