For problem statement at 0-999/800-899/860-869/864/problemD.txt this is a correct solution, but verifier at 0-999/800-899/860-869/864/verifierD.go ends with case 1 failed: runtime error: exit status 2
panic: runtime error: index out of range [27] with length 15
goroutine 1 [running]:
main.main()
/tmp/build-557715780/solution.go:32 +0x5a4
input:14
27 6 15 24 17 19 7 9 10 9 5 6 16 2
exit status 1 can you fix the verifier? ```go
package main
import (
"bufio"
"container/heap"
"fmt"
"os"
)
type IntHeap []int
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.(int)) }
func (h *IntHeap) Pop() interface{} {
old := *h
n := len(old)
x := old[n-1]
*h = old[:n-1]
return x
}
func main() {
in := bufio.NewReader(os.Stdin)
var n int
fmt.Fscan(in, &n)
a := make([]int, n)
cnt := make([]int, n+1)
for i := 0; i < n; i++ {
fmt.Fscan(in, &a[i])
cnt[a[i]]++
}
missing := &IntHeap{}
heap.Init(missing)
for v := 1; v <= n; v++ {
if cnt[v] == 0 {
heap.Push(missing, v)
}
}
changed := 0
for i := 0; i < n; i++ {
x := a[i]
if cnt[x] == 1 {
continue
}
if missing.Len() == 0 {
continue
}
m := (*missing)[0]
if m < x {
heap.Pop(missing)
cnt[x]--
a[i] = m
changed++
} else if cnt[x] > 1 {
heap.Pop(missing)
cnt[x]--
a[i] = m
changed++
}
}
out := bufio.NewWriter(os.Stdout)
fmt.Fprintln(out, changed)
for i := 0; i < n; i++ {
if i > 0 {
fmt.Fprint(out, " ")
}
fmt.Fprint(out, a[i])
}
fmt.Fprintln(out)
out.Flush()
}
```