For problem statement at 1000-1999/1800-1899/1860-1869/1862/problemE.txt this is a correct solution, but verifier at 1000-1999/1800-1899/1860-1869/1862/verifierE.go ends with All 100 tests passed can you fix the verifier? package main
import (
"bufio"
"container/heap"
"fmt"
"os"
)
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 readInt(in *bufio.Reader) int64 {
var n int64
var c byte
var err error
var sign int64 = 1
for {
c, err = in.ReadByte()
if err != nil {
return 0
}
if c == '-' {
sign = -1
continue
}
if c >= '0' && c <= '9' {
n = int64(c - '0')
break
}
}
for {
c, err = in.ReadByte()
if err != nil || c < '0' || c > '9' {
break
}
n = n*10 + int64(c-'0')
}
return n * sign
}
func main() {
in := bufio.NewReader(os.Stdin)
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
t := int(readInt(in))
for i := 0; i < t; i++ {
n := int(readInt(in))
m := int(readInt(in))
d := readInt(in)
h := &IntHeap{}
var sum int64 = 0
var maxVal int64 = 0
for j := 1; j <= n; j++ {
a := readInt(in)
if a > 0 {
heap.Push(h, a)
sum += a
if h.Len() > m {
sum -= heap.Pop(h).(int64)
}
}
ans := sum - d*int64(j)
if ans > maxVal {
maxVal = ans
}
}
fmt.Fprintln(out, maxVal)
}
}