Skip to content

Commit 703cfa2

Browse files
committed
[2400] CF1251E2 转换 贪心 堆
1 parent 4dab05d commit 703cfa2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

main/1200-1299/1251E2.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
)
1010

1111
// github.com/EndlessCheng/codeforces-go
12-
type hp struct{ sort.IntSlice }
12+
type hp51 struct{ sort.IntSlice }
1313

14-
func (h *hp) Push(v interface{}) { h.IntSlice = append(h.IntSlice, v.(int)) }
15-
func (h *hp) Pop() interface{} { a := h.IntSlice; v := a[len(a)-1]; h.IntSlice = a[:len(a)-1]; return v }
14+
func (h *hp51) Push(v interface{}) { h.IntSlice = append(h.IntSlice, v.(int)) }
15+
func (h *hp51) Pop() interface{} { a := h.IntSlice; v := a[len(a)-1]; h.IntSlice = a[:len(a)-1]; return v }
1616

1717
func CF1251E2(_r io.Reader, _w io.Writer) {
1818
in := bufio.NewReader(_r)
@@ -31,7 +31,7 @@ func CF1251E2(_r io.Reader, _w io.Writer) {
3131
// 维护最小 pi 可以用最小堆
3232
sort.Slice(a, func(i, j int) bool { a, b := a[i], a[j]; return a.m < b.m || a.m == b.m && a.p < b.p })
3333
ans := int64(0)
34-
for i, buy, h := n-1, 0, new(hp); i >= 0; i-- {
34+
for i, buy, h := n-1, 0, new(hp51); i >= 0; i-- {
3535
heap.Push(h, a[i].p)
3636
if a[i].m > i+buy {
3737
buy++

0 commit comments

Comments
 (0)