Submission #483955

#TimeUsernameProblemLanguageResultExecution timeMemory
483955tibiCoderJob Scheduling (CEOI12_jobs)C++11
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <string> #include <fstream> #include <tuple> #include <cmath> #include <algorithm> #include <map> #include <set> #include <climits> #include <unordered_map> #include <queue> #include <cstdio> #include <cstring> #include <numeric> #include <bitset> #include <iomanip> using namespace std; struct Event { int time; int arrival; bool isEnd; bool operator>(const Event& other) const { if (time == other.time) { if (isEnd == other.isEnd) { return arrival > other.arrival; } return !isEnd && other.isEnd; } return time > other.time; } }; bool isPossibleForMachines(vector<int>& jobs, int maxDelay, int nOfMachines) { priority_queue<Event, vector<Event>, greater<>> nextFreeMachine; for (int & job : jobs) { nextFreeMachine.push({job, job, false}); } while (!nextFreeMachine.empty()) { Event event = nextFreeMachine.top(); nextFreeMachine.pop(); while (!nextFreeMachine.empty() && nextFreeMachine.top().isEnd && nextFreeMachine.top().time==event.time) { nextFreeMachine.pop(); ++nOfMachines; } if (event.isEnd) { ++nOfMachines; continue; } if (nOfMachines > 0) { --nOfMachines; if (event.time-event.arrival > maxDelay) { return false; } nextFreeMachine.push({event.time+1, event.arrival, true}); } else { nextFreeMachine.push({event.time+1, event.arrival, false}); } } return true; } int main() { int nOfDays, maxDelay, nOfJobRequests; cin >> nOfDays >> maxDelay >> nOfJobRequests; vector<int> jobs(nOfJobRequests); for (int i = 0; i < nOfJobRequests; ++i) { cin >> jobs[i]; } std::sort(jobs.begin(), jobs.end()); int start = 1; int end = 1000000; int low; while (start <= end) { int middle = start + (end-start)/2; if (isPossibleForMachines(jobs, maxDelay, middle)) { low = middle; end = middle-1; } else { start = middle+1; } } cout << low << "\n0\n0\n"; return 0; }

Compilation message (stderr)

jobs.cpp: In function 'bool isPossibleForMachines(std::vector<int>&, int, int)':
jobs.cpp:39:49: error: wrong number of template arguments (0, should be 1)
   39 |     priority_queue<Event, vector<Event>, greater<>> nextFreeMachine;
      |                                                 ^
In file included from /usr/include/c++/10/string:48,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from jobs.cpp:1:
/usr/include/c++/10/bits/stl_function.h:371:12: note: provided for 'template<class _Tp> struct std::greater'
  371 |     struct greater : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~
jobs.cpp:39:50: error: template argument 3 is invalid
   39 |     priority_queue<Event, vector<Event>, greater<>> nextFreeMachine;
      |                                                  ^~
jobs.cpp:41:25: error: request for member 'push' in 'nextFreeMachine', which is of non-class type 'int'
   41 |         nextFreeMachine.push({job, job, false});
      |                         ^~~~
jobs.cpp:44:29: error: request for member 'empty' in 'nextFreeMachine', which is of non-class type 'int'
   44 |     while (!nextFreeMachine.empty()) {
      |                             ^~~~~
jobs.cpp:45:39: error: request for member 'top' in 'nextFreeMachine', which is of non-class type 'int'
   45 |         Event event = nextFreeMachine.top();
      |                                       ^~~
jobs.cpp:46:25: error: request for member 'pop' in 'nextFreeMachine', which is of non-class type 'int'
   46 |         nextFreeMachine.pop();
      |                         ^~~
jobs.cpp:47:33: error: request for member 'empty' in 'nextFreeMachine', which is of non-class type 'int'
   47 |         while (!nextFreeMachine.empty() && nextFreeMachine.top().isEnd && nextFreeMachine.top().time==event.time) {
      |                                 ^~~~~
jobs.cpp:47:60: error: request for member 'top' in 'nextFreeMachine', which is of non-class type 'int'
   47 |         while (!nextFreeMachine.empty() && nextFreeMachine.top().isEnd && nextFreeMachine.top().time==event.time) {
      |                                                            ^~~
jobs.cpp:47:91: error: request for member 'top' in 'nextFreeMachine', which is of non-class type 'int'
   47 |         while (!nextFreeMachine.empty() && nextFreeMachine.top().isEnd && nextFreeMachine.top().time==event.time) {
      |                                                                                           ^~~
jobs.cpp:48:29: error: request for member 'pop' in 'nextFreeMachine', which is of non-class type 'int'
   48 |             nextFreeMachine.pop();
      |                             ^~~
jobs.cpp:60:29: error: request for member 'push' in 'nextFreeMachine', which is of non-class type 'int'
   60 |             nextFreeMachine.push({event.time+1, event.arrival, true});
      |                             ^~~~
jobs.cpp:63:29: error: request for member 'push' in 'nextFreeMachine', which is of non-class type 'int'
   63 |             nextFreeMachine.push({event.time+1, event.arrival, false});
      |                             ^~~~