Submission details
Task:Entrepreneur
Sender:aalto25a_004
Submission time:2025-09-03 17:50:00 +0300
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:21:5: error: 'priority_queue' was not declared in this scope
   21 |     priority_queue<pair<int,int> , vector<pair<int,int>>, greater<pair<int,int>> > pq;
      |     ^~~~~~~~~~~~~~
input/code.cpp:3:1: note: 'std::priority_queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    2 | #include <algorithm>
  +++ |+#include <queue>
    3 | #include <unordered_map>
input/code.cpp:21:34: error: expected primary-expression before ',' token
   21 |     priority_queue<pair<int,int> , vector<pair<int,int>>, greater<pair<int,int>> > pq;
      |                                  ^
input/code.cpp:21:57: error: expected primary-expression before ',' token
   21 |     priority_queue<pair<int,int> , vector<pair<int,int>>, greater<pair<int,int>> > pq;
      |                                                         ^
input/code.cpp:21:82: error: expected primary-expression before '>' token
   21 |     priority_queue<pair<in...

Code

#include <iostream>
#include <algorithm>
#include <unordered_map>

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(){
    long long n, t;

    cin >> n;
    cin >> t;
    // n number of machines, t number of cars



    unordered_map<int, long long> man_times;
    priority_queue<pair<int,int> , vector<pair<int,int>>, greater<pair<int,int>> > pq;
    priority_queue<pair<int,int> , vector<pair<int,int>>, greater<pair<int,int>> > nq;
    priority_queue<pair<int,int> , vector<pair<int,int>>, greater<pair<int,int>> > temp;

    long long b;
    int i = 0;
    while (cin >> b)
    {
        man_times[i++] = b;
        pq.push(make_pair(b, i));
    }

    long long cars = 0;
    long long time = 0;

    while (cars < t)
    {   
        pair<int,int> top = pq.top();
        int min_time = top.first;
        while (!pq.empty()) {
            pair<int, int> cur = pq.top();
            pq.pop();
            int k = cur.first;
            if (k == min_time)
            {
                ++cars;
                nq.push(make_pair(i, man_times[cur.second]));
            }
            else
            {
                nq.push(make_pair(i, k - min_time));
            }
        }
        temp = pq;
        pq = nq;
        nq = temp;

        time += min_time;

    }

    

    cout << time;
    return 0;
}