← Home
For problem statement at 1000-1999/1400-1499/1410-1419/1415/problemE.txt this is a correct solution, but verifier at 1000-1999/1400-1499/1410-1419/1415/verifierE.go ends with All 100 tests passed can you fix the verifier? ```go
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
)

type IntHeap []int64

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] } 
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int64))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	in := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var readInt func() int64
	readInt = func() int64 {
		var n int64 = 0
		var sign int64 = 1
		var c byte
		var err error
		for {
			c, err = in.ReadByte()
			if err != nil {
				return 0
			}
			if c == '-' || (c >= '0' && c <= '9') {
				break
			}
		}
		if c == '-' {
			sign = -1
			c, err = in.ReadByte()
			if err != nil {
				return 0
			}
		}
		for c >= '0' && c <= '9' {
			n = n*10 + int64(c-'0')
			c, err = in.ReadByte()
			if err != nil {
				break
			}
		}
		return n * sign
	}

	n := int(readInt())
	k := int(readInt())

	c := make([]int64, n)
	for i := 0; i < n; i++ {
		c[i] = readInt()
	}

	sort.Slice(c, func(i, j int) bool {
		return c[i] > c[j]
	})

	m := k + 1
	if m > n {
		m = n
	}

	h := make(IntHeap, m)
	for i := 0; i < m; i++ {
		h[i] = 0
	}

	var score int64 = 0

	for i := 0; i < n; i++ {
		x := c[i]
		score += h[0]
		h[0] += x
		heap.Fix(&h, 0)
	}

	fmt.Println(score)
}
```