For problem statement at 1000-1999/1700-1799/1710-1719/1718/problemB.txt this is a correct solution, but verifier at 1000-1999/1700-1799/1710-1719/1718/verifierB.go ends with All 100 tests passed can you fix the verifier? package main
import (
"bufio"
"fmt"
"os"
)
func main() {
reader := bufio.NewReader(os.Stdin)
var t int
if _, err := fmt.Fscan(reader, &t); err != nil {
return
}
for i := 0; i < t; i++ {
var k int
fmt.Fscan(reader, &k)
counts := make([]int64, k)
var S int64 = 0
for j := 0; j < k; j++ {
fmt.Fscan(reader, &counts[j])
S += counts[j]
}
f := make([]int64, 0)
if S == 1 {
f = append(f, 1)
} else {
f = append(f, 1, 1)
var total int64 = 2
for total < S {
nextF := f[len(f)-1] + f[len(f)-2]
f = append(f, nextF)
total += nextF
}
if total != S {
fmt.Println("NO")
continue
}
}
possible := true
prevIdx := -1
for j := len(f) - 1; j >= 0; j-- {
var maxVal int64 = -1
maxIdx := -1
for idx := 0; idx < k; idx++ {
if idx == prevIdx {
continue
}
if counts[idx] > maxVal {
maxVal = counts[idx]
maxIdx = idx
}
}
if maxVal < f[j] {
possible = false
break
}
counts[maxIdx] -= f[j]
prevIdx = maxIdx
}
if possible {
fmt.Println("YES")
} else {
fmt.Println("NO")
}
}
}