- Arrays, cpp-priority-queue, Greedy, Mathematical, priority-queue, Sorting

Maximize product of sum of speeds of K workers and their minimum efficiency

#include using namespace std;  void generateArrayofPairs(int n, vector& speed,                          vector& efficiency,                          vector& arr){      for (int i = 0; i < n; i++) {          arr[i] = { efficiency[i], speed[i] };    }      sort(arr.rbegin(), arr.rend());}  int maximizePerformance(vector& speed, int K,                        vector& efficiency){      int n = speed.size();    vector arr(n);              generateArrayofPairs(n, speed,                         efficiency, arr);          priority_queue        pq;          int ans = 0;    int SumOfSpeed = 0;          for (auto& it : arr) {          int e = it.first;        int s = it.second;                  SumOfSpeed += s;                  pq.push(s);                          if (pq.size() > K) {              int temp = pq.top();            SumOfSpeed -= temp;            pq.pop();        }                          ans = max(ans, SumOfSpeed * e);    }          return ans;}  int main(){        vector speed = { 2, 10, 3, 1, 5, 8 };    vector efficiency = { 5, 4, 3, 9, 7, 2 };    int K = 2;          cout