Skip to content

Commit 60f8f00

Browse files
committed
fix 2542
1 parent a9a0d12 commit 60f8f00

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

go/heap/2542/2542.最大子序列的分数.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ func maxScore(nums1, nums2 []int, k int) int64 {
9292
heap.Init(&h)
9393
for _, p := range a[k:] {
9494
if p.x > h.IntSlice[0] {
95-
x := heap.Pop(&h).(int)
95+
x, ok := heap.Pop(&h).(int)
96+
if !ok {
97+
continue
98+
}
9699
sum += p.x - x
97100
heap.Push(&h, p.x)
98101
ans = max(ans, sum*p.y)

0 commit comments

Comments
 (0)