← 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 17 failed: expected "7" got "12"
input:
1
3 4
1 2 5 can you fix the verifier? package main

import (
	"bufio"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	nextToken := func() int {
		scanner.Scan()
		res, _ := strconv.Atoi(scanner.Text())
		return res
	}

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())

	for tc := 0; tc < t; tc++ {
		n := nextToken()
		k := nextToken()

		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = nextToken()
		}

		p := int64(1)
		j := 0
		for d := 0; d < k; d++ {
			for j < n && int64(a[j]-(j+1)) < p {
				j++
			}
			p += int64(j)
		}

		out.WriteString(strconv.FormatInt(p, 10))
		out.WriteByte('\n')
	}
}