Submission #384252

# Submission time Handle Problem Language Result Execution time Memory
384252 2021-04-01T01:13:30 Z MalachiN Job Scheduling (CEOI12_jobs) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
int N, D, M;
int jobs[10000001];
bool test(int x){
    int tracker = 0;
    for (int n = 1; n <= N; n++){
        int itter = tracker;
        for (int c = itter; c < itter+x; c++){
            if (tracker < M){
                if (jobs[tracker] <= n){
                    if (jobs[tracker]+D < n){
                        return false;
                    }
                    tracker++;
                }
                else {
                    break;
                }
                
            }
            else {
                return true;
            }
  
        }
    }
    return true;
}
int main(int argc, const char * argv[]) {
    //ifstream cin ("file.in"); ofstream cout ("file.out");
 
    cin >> N >> D >> M;
    for (int m = 0; m < M; m++){
        cin >> jobs[m];
    }
    sort(jobs, jobs + M);
    int low = 1;
    int high = 1000000000;
    while (low < high){
        int middle = (low + high)/2;
     //   cout << "High: " << high << " Low: " << low << " Middle: " << middle << endl;
        if (test(middle)){
            if (middle == 1){
       //         cout << "ONE";
            }
            high = middle;
        }
        else {
            low = middle + 1;
        }
        
            
    }
    cout << low;
    

}

Compilation message

jobs.cpp: In function 'int main(int, const char**)':
jobs.cpp:39:5: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   39 |     sort(jobs, jobs + M);
      |     ^~~~
      |     qsort