For problem statement at 1000-1999/1700-1799/1760-1769/1765/problemJ.txt this is a correct solution, but verifier at 1000-1999/1700-1799/1760-1769/1765/verifierJ.go ends with test 2 failed: expected 9 but got 13
input:
3
1 3 5
2 4 6
expected:
9
actual:
13
exit status 1 can you fix the verifier? ```go
package main
import (
"fmt"
"io"
"os"
"sort"
)
func main() {
input, _ := io.ReadAll(os.Stdin)
var pos int
nextInt := func() int64 {
for pos < len(input) && (input[pos] < '0' || input[pos] > '9') {
pos++
}
if pos >= len(input) {
return 0
}
var res int64
for pos < len(input) && input[pos] >= '0' && input[pos] <= '9' {
res = res*10 + int64(input[pos]-'0')
pos++
}
return res
}
n := int(nextInt())
if n == 0 {
return
}
A := make([]int64, n)
for i := 0; i < n; i++ {
A[i] = nextInt()
}
B := make([]int64, n)
for i := 0; i < n; i++ {
B[i] = nextInt()
}
sort.Slice(A, func(i, j int) bool { return A[i] < A[j] })
sort.Slice(B, func(i, j int) bool { return B[i] < B[j] })
var sumW int64 = 0
for i := 0; i < n; i++ {
diff := A[i] - B[i]
if diff < 0 {
sumW -= diff
} else {
sumW += diff
}
}
prefB := make([]int64, n+1)
for i := 0; i < n; i++ {
prefB[i+1] = prefB[i] + B[i]
}
var sumC int64 = 0
k := 0
for i := 0; i < n; i++ {
for k < n && B[k] <= A[i] {
k++
}
sumC += int64(k)*A[i] - prefB[k]
sumC += (prefB[n] - prefB[k]) - int64(n-k)*A[i]
}
ans := sumC - int64(n-1)*sumW
fmt.Println(ans)
}
```