← Home
For problem statement at 1000-1999/1800-1899/1850-1859/1852/problemA.txt this is a correct solution, but verifier at 1000-1999/1800-1899/1850-1859/1852/verifierA.go ends with case 6 failed: expected "2" got "1"
input:
1
1 1
1 can you fix the verifier? ```go
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	next := func() string {
		scanner.Scan()
		return scanner.Text()
	}

	t, _ := strconv.Atoi(next())
	for tc := 0; tc < t; tc++ {
		n, _ := strconv.Atoi(next())
		k, _ := strconv.Atoi(next())
		a := make([]int64, n)
		for i := 0; i < n; i++ {
			val, _ := strconv.ParseInt(next(), 10, 64)
			a[i] = val
		}

		ans := int64(1)
		for i := 0; i < k; i++ {
			low := ans
			high := ans + int64(n)
			for low < high {
				mid := (low + high) / 2
				cnt := sort.Search(n, func(i int) bool { return a[i] >= mid })
				if mid - int64(cnt) >= ans {
					high = mid
				} else {
					low = mid + 1
				}
			}
			ans = low
		}
		fmt.Fprintln(writer, ans)
	}
}
```