Submission #924697

# Submission time Handle Problem Language Result Execution time Memory
924697 2024-02-09T13:46:23 Z tz74 Job Scheduling (CEOI12_jobs) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

int N, D, M;
deque<pair<int, int> > rq_base;

bool check(int n_machines, bool show) {
    int available = n_machines;
    deque<int> current;
    deque<pair<int, int> > pending;
    deque<pair<int, int> > rq = rq_base;

    for (int day = 1; day <= N; day++) {
        while (!current.empty() && current.front() <= day) {
            available++;
            current.pop_front();
        }

        while (!rq.empty() && rq.front().first <= day) {
            auto f = rq.front();
            pending.push_back(make_pair(f.first + D, f.second));
            rq.pop_front();
        }

        // pop the ones that have tightest requirements
        while (available != 0 && !pending.empty()) {
            int need = pending.begin()->first;
            if (need < day) {
                return false;
            }

            if (show) printf("%d ", pending.begin()->second);

            // will get this printer back the next day
            current.push_back(day + 1);
            pending.erase(pending.begin());
            available--;
        }

        if (show) printf("0\n");
    }

    return true;
}

int main(void) {
    cin >> N >> D >> M;

    for (int i = 1; i <= M; i++) {
        int d; cin >> d;
        rq_base.push_back(make_pair(d, i));
    }
    std::sort(rq_base.begin(), rq_base.end());

    int lo = 1, hi = 1e6;
    while (lo < hi) {
        int mid = (lo + hi) / 2;

        if (check(mid, 0)) {
            hi = mid;
        } else {
            lo = mid + 1;
        }
    }

    printf("%d\n", lo);
    check(lo, 1);
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:56:10: error: 'sort' is not a member of 'std'
   56 |     std::sort(rq_base.begin(), rq_base.end());
      |          ^~~~