JavaScript and TypeScript Solution
JavaScript AC (932 ms, 69.7 MB)\njs\n/**\n * @param {number[][]} classes\n * @param {number} extraStudents\n * @return {number}\n */\nvar maxAverageRatio = func
JavaScript AC (932 ms, 69.7 MB)\n```js\n/**\n * @param {number[][]} classes\n * @param {number} extraStudents\n * @return {number}\n */\nvar maxAverageRatio = function(classes, extraStudents) {\n  const q = new MaxPriorityQueue({\n    priority: i => (classes[i][0] + 1) / (classes[i][1] + 1) - \n      classes[i][0] / classes[i][1],\n  });\n  classes.forEach((_, i) => {\n    q.enqueue(i);\n  });\n  \n  let es = extraStudents;\n  while (es) {\n    const i = q.dequeue().element;\n    \n    classes[i][0] += 1;\n    classes[i][1] += 1;\n    q.enqueue(i);\n    \n    es -= 1;\n  }\n  \n  let sum = 0;\n  classes.forEach(([p, t]) => {\n    sum += p / t;\n  });\n  \n  return sum / classes.length;\n};\n```\n\nTypeScript AC (924 ms\t71.6 MB)\n```ts\nfunction maxAverageRatio(classes: number[][], extraStudents: number): number {\n  const q = new MaxPriorityQueue({\n    priority: i => (classes[i][0] + 1) / (classes[i][1] + 1) - \n      classes[i][0] / classes[i][1],\n  });\n  classes.forEach((_, i) => {\n    q.enqueue(i);\n  });\n  \n  let es = extraStudents;\n  while (es) {\n    const i = q.dequeue().element;\n    \n    classes[i][0] += 1;\n    classes[i][1] += 1;\n    q.enqueue(i);\n    \n    es -= 1;\n  }\n  \n  let sum = 0;\n  classes.forEach(([p, t]) => {\n    sum += p / t;\n  });\n  \n  return sum / classes.length;\n};\n```
[]