For problem statement at 1000-1999/1800-1899/1890-1899/1893/problemC.txt this is a correct solution, but verifier at 1000-1999/1800-1899/1890-1899/1893/verifierC.go ends with All tests passed can you fix the verifier? ```go
package main
import (
"bufio"
"os"
"sort"
"strconv"
)
const maxBufSize = 20 * 1024 * 1024
var sc = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)
func init() {
sc.Split(bufio.ScanWords)
buf := make([]byte, 0, maxBufSize)
sc.Buffer(buf, maxBufSize)
}
func scanInt() int {
sc.Scan()
x, _ := strconv.Atoi(sc.Text())
return x
}
func scanInt64() int64 {
sc.Scan()
x, _ := strconv.ParseInt(sc.Text(), 10, 64)
return x
}
type Entry struct {
Val int64
MIdx int
Count int64
}
type Multiset struct {
L, R, C int64
}
func main() {
defer writer.Flush()
if !sc.Scan() {
return
}
t, _ := strconv.Atoi(sc.Text())
for i := 0; i < t; i++ {
solve()
}
}
func solve() {
m := scanInt()
multisets := make([]Multiset, m)
entries := make([]Entry, 0, m*2)
var totalL, totalR int64
for i := 0; i < m; i++ {
n := scanInt()
l := scanInt64()
r := scanInt64()
vals := make([]int64, n)
for j := 0; j < n; j++ {
vals[j] = scanInt64()
}
var cSum int64
counts := make([]int64, n)
for j := 0; j < n; j++ {
cc := scanInt64()
counts[j] = cc
cSum += cc
}
multisets[i] = Multiset{L: l, R: r, C: cSum}
totalL += l
totalR += r
for j := 0; j < n; j++ {
entries = append(entries, Entry{Val: vals[j], MIdx: i, Count: counts[j]})
}
}
sort.Slice(entries, func(i, j int) bool {
return entries[i].Val < entries[j].Val
})
type Group struct {
Val int64
Start, End int
}
var validGroups []Group
nEntries := len(entries)
cntValid := int64(0)
for i := 0; i < nEntries; {
val := entries[i].Val
j := i
for j < nEntries && entries[j].Val == val {
j++
}
if val >= totalL && val <= totalR {
validGroups = append(validGroups, Group{Val: val, Start: i, End: j})
cntValid++
}
i = j
}
rangeLen := totalR - totalL + 1
if cntValid < rangeLen {
writer.WriteString("0\n")
return
}
minCost := int64(-1)
for _, g := range validGroups {
S := g.Val
var sumA int64 = 0
var sumB_term int64 = 0
for k := g.Start; k < g.End; k++ {
e := entries[k]
idx := e.MIdx
cnt := e.Count
ms := multisets[idx]
// A term contribution: max(0, l_i - (C_i - c_i,S))
valA := ms.L - ms.C + cnt
if valA > 0 {
sumA += valA
}
// B term part: max(0, r_i - (C_i - c_i,S))
valB := ms.R - ms.C + cnt
if valB > 0 {
sumB_term += valB
}
}
costA := sumA
// B = S - R + sum(max(0, r_i - (C_i - c_i,S)))
costB := S - totalR + sumB_term
currentCost := costA
if costB > costA {
currentCost = costB
}
if minCost == -1 || currentCost < minCost {
minCost = currentCost
}
}
if minCost == -1 {
minCost = 0
}
writer.WriteString(strconv.FormatInt(minCost, 10))
writer.WriteByte('\n')
}
```