Submission #975668

# Submission time Handle Problem Language Result Execution time Memory
975668 2024-05-05T17:09:16 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
Compilation error
0 ms 0 KB

#include <iostream>
#include <vector>


using namespace std;


int n, m, d;
vector< pair<int,int> > jobs;


bool isok(int x) {//each day can process x jobs.
   int j = 0;
   for (int i = 1; i <= n; i++) {
       int count = x;
       while (j < m && jobs[j].first <= i && count > 0) {
           if (i - jobs[j].first > d) return false;
           j++;
           count--;
       }
   }
   return j == m;
}


int main() {
   cin >> n >> d >> m;
   jobs = vector< pair<int,int> >(m);
   for (int i = 0; i < m; i++) {
       cin >> jobs[i].first;
       jobs[i].second = i+1;
   }
   sort(jobs.begin(),jobs.end());
   int l = 1, r = m;
   int mid;
   int ans;
   while (l <= r) {
       mid = (l+r)/2;
       if (isok(mid)) {
           ans = mid;
           r = mid -1;
       }
       else {l = mid+1; }
   }
   cout << ans << '\n';
   int j = 0;
   for (int i = 1; i <= n; i++) {
       int count = ans;
       while (j < m && jobs[j].first <= i && count > 0) {
           cout << jobs[j].second << " ";
           j++;
           count--;
       }
       cout << 0 << endl;
   }
   return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:35:4: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   35 |    sort(jobs.begin(),jobs.end());
      |    ^~~~
      |    qsort