Skip to content

Commit 79d5ddd

Browse files
authored
Update 1383-maximum-performance-of-a-team.js
1 parent 6b16af1 commit 79d5ddd

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

1383-maximum-performance-of-a-team.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ const maxPerformance = function (n, speed, efficiency, k) {
1111
const pq = new PriorityQueue({
1212
comparator: (a, b) => a <= b,
1313
})
14-
const M = 10 ** 9 + 7
15-
let sumOfSpeed = 0
16-
let max = 0
14+
const M = BigInt(10 ** 9 + 7)
15+
let sumOfSpeed = BigInt(0)
16+
let max = BigInt(0)
1717
for (const [s, e] of arr) {
1818
pq.enqueue(s)
1919
sumOfSpeed += s
2020
if (pq.length > k) {
2121
sumOfSpeed -= pq.dequeue()
2222
}
23-
max = Math.max(max, sumOfSpeed * e)
23+
const tmp = sumOfSpeed * BigInt(e)
24+
if(tmp > max) max = tmp
2425
}
25-
if (max === 125026844176762060) return 301574164
2626
return max % M
2727
}
2828

2929
function zip(arr1, arr2) {
3030
const arr = []
3131
for (let i = 0; i < arr1.length; i++) {
32-
arr.push([arr1[i], arr2[i]])
32+
arr.push([BigInt(arr1[i]), arr2[i]])
3333
}
3434
return arr
3535
}
@@ -81,7 +81,6 @@ function moveDown(arr, i, comparator) {
8181
}
8282
}
8383

84-
8584
// another
8685

8786
const MinHeap = () => {

0 commit comments

Comments
 (0)