← Home
For problem statement at 2000-2999/2000-2099/2040-2049/2042/problemC.txt this is a correct solution, but verifier at 2000-2999/2000-2099/2040-2049/2042/verifierC.go ends with All tests passed can you fix the verifier? ```go
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	if _, err := fmt.Fscan(in, &t); err != nil {
		return
	}

	for i := 0; i < t; i++ {
		var n int
		var k int64
		fmt.Fscan(in, &n, &k)
		var s string
		fmt.Fscan(in, &s)

		// We compute the suffix sums for the score difference.
		// A cut after index j (0-based) contributes to the total score difference
		// by an amount equal to the net score of the suffix starting at j+1.
		// Net score for a substring is count('1') - count('0').
		// Possible cuts are after index 0, 1, ..., n-2.
		// Corresponding suffixes start at 1, 2, ..., n-1.

		contributions := make([]int, 0, n-1)
		currentSuffixSum := 0

		// Iterate backwards to compute suffix sums efficiently
		for j := n - 1; j >= 1; j-- {
			if s[j] == '1' {
				currentSuffixSum++
			} else {
				currentSuffixSum--
			}
			contributions = append(contributions, currentSuffixSum)
		}

		// Sort contributions in descending order to pick the best cuts greedily
		sort.Ints(contributions)
		
		// Initial difference with 1 group is 0.
		// We need diff >= k.
		// We pick positive contributions until we reach k.
		
		ans := -1
		var currentDiff int64 = 0
		cuts := 0
		
		// Iterate from largest value (end of sorted slice)
		for j := len(contributions) - 1; j >= 0; j-- {
			val := contributions[j]
			if val <= 0 {
				break
			}
			currentDiff += int64(val)
			cuts++
			if currentDiff >= k {
				ans = cuts + 1
				break
			}
		}

		fmt.Fprintln(out, ans)
	}
}
```