For problem statement at 1000-1999/1200-1299/1200-1209/1203/problemE.txt this is a correct solution, but verifier at 1000-1999/1200-1299/1200-1209/1203/verifierE.go ends with All tests passed can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
if !scanner.Scan() {
return
}
n, _ := strconv.Atoi(scanner.Text())
counts := make([]int, 150002)
for i := 0; i < n; i++ {
scanner.Scan()
w, _ := strconv.Atoi(scanner.Text())
counts[w]++
}
ans := 0
lastUsed := 0
for w := 1; w <= 150000; w++ {
for counts[w] > 0 {
if w-1 > lastUsed && w-1 >= 1 {
lastUsed = w - 1
ans++
counts[w]--
} else if w > lastUsed {
lastUsed = w
ans++
counts[w]--
} else if w+1 > lastUsed {
lastUsed = w + 1
ans++
counts[w]--
} else {
break
}
}
}
fmt.Println(ans)
}