- Arrays, Greedy, Mathematical, priority-queue, Ratio and Proportion

Maximize sum of ratios of N given fractions by incrementing numerator and denominators K times by 1

  #include using namespace std;  double maxAverageRatio(    vector& arr, int K){        int N = arr.size();          priority_queue q;          for (int i = 0; i < N; i++) {                                  double extra            = (((double)arr[i][0] + 1)               / ((double)arr[i][1] + 1))              - ((double)arr[i][0]                 / (double)arr[i][1]);        q.push(make_pair(extra, i));    }          while (K--) {        int i = q.top().second;        q.pop();                          arr[i][0] += 1;        arr[i][1] += 1;                  double extra            = (((double)arr[i][0] + 1)               / ((double)arr[i][1] + 1))              - ((double)arr[i][0]                 / (double)arr[i][1]);          q.push(make_pair(extra, i));    }          double ans = 0;    for (int i = 0; i < N; i++) {        ans += ((double)arr[i][0]                / (double)arr[i][1]);    }          return ans / N;}  int main(){    vector arr        = { { 1, 2 }, { 3, 5 }, { 2, 2 } };    int K = 2;      cout