For problem statement at 1000-1999/1700-1799/1720-1729/1728/problemC.txt this is a correct solution, but verifier at 1000-1999/1700-1799/1720-1729/1728/verifierC.go ends with case 2 failed: expected 2 got 0
input:
1
3
1 2 3
3 2 1
exit status 1 can you fix the verifier? package main
import (
"bufio"
"os"
"sort"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
scanner.Buffer(make([]byte, 1024*1024), 1024*1024*10)
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
if !scanner.Scan() {
return
}
t, _ := strconv.Atoi(scanner.Text())
for test := 0; test < t; test++ {
scanner.Scan()
n, _ := strconv.Atoi(scanner.Text())
a := make([]int, n)
for i := 0; i < n; i++ {
scanner.Scan()
a[i], _ = strconv.Atoi(scanner.Text())
}
b := make([]int, n)
for i := 0; i < n; i++ {
scanner.Scan()
b[i], _ = strconv.Atoi(scanner.Text())
}
sort.Ints(a)
sort.Ints(b)
ans := 0
var countA, countB [11]int
i, j := 0, 0
for i < n && j < n {
if a[i] == b[j] {
i++
j++
} else if a[i] < b[j] {
if a[i] >= 10 {
ans++
countA[length(a[i])]++
} else {
countA[a[i]]++
}
i++
} else {
if b[j] >= 10 {
ans++
countB[length(b[j])]++
} else {
countB[b[j]]++
}
j++
}
}
for i < n {
if a[i] >= 10 {
ans++
countA[length(a[i])]++
} else {
countA[a[i]]++
}
i++
}
for j < n {
if b[j] >= 10 {
ans++
countB[length(b[j])]++
} else {
countB[b[j]]++
}
j++
}
for v := 2; v <= 9; v++ {
m := countA[v]
if countB[v] < m {
m = countB[v]
}
countA[v] -= m
countB[v] -= m
ans += countA[v] + countB[v]
}
out.WriteString(strconv.Itoa(ans) + "\n")
}
}
func length(x int) int {
if x < 10 {
return 1
}
if x < 100 {
return 2
}
if x < 1000 {
return 3
}
if x < 10000 {
return 4
}
if x < 100000 {
return 5
}
if x < 1000000 {
return 6
}
if x < 10000000 {
return 7
}
if x < 100000000 {
return 8
}
if x < 1000000000 {
return 9
}
return 10
}