← Home
For problem statement at 1000-1999/1200-1299/1250-1259/1257/problemD.txt this is a correct solution, but verifier at 1000-1999/1200-1299/1250-1259/1257/verifierD.go ends with case 3 failed: line 1 expected 2 got 1
input:
3
5
6 1 6 1 2
8 1
9 3
5 4
5
7 5 7 1 9
1 1
3 5
8 2
9 4
2 3
1
2
1 1
exit status 1 can you fix the verifier? ```go
package main

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

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

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

	if scanner.Scan() {
		t, _ := strconv.Atoi(scanner.Text())
		for i := 0; i < t; i++ {
			n := scanInt()
			a := make([]int, n)
			for j := 0; j < n; j++ {
				a[j] = scanInt()
			}

			m := scanInt()
			bestP := make([]int, n+1)
			for j := 0; j < m; j++ {
				p := scanInt()
				s := scanInt()
				if s > n {
					s = n
				}
				if p > bestP[s] {
					bestP[s] = p
				}
			}

			for j := n - 1; j >= 1; j-- {
				if bestP[j+1] > bestP[j] {
					bestP[j] = bestP[j+1]
				}
			}

			days := 0
			curr := 0
			possible := true

			for curr < n {
				days++
				step := 0
				mx := 0
				for curr+step < n {
					if a[curr+step] > mx {
						mx = a[curr+step]
					}
					if mx > bestP[step+1] {
						break
					}
					step++
				}

				if step == 0 {
					possible = false
					break
				}
				curr += step
			}

			if possible {
				writer.WriteString(strconv.Itoa(days))
				writer.WriteByte('\n')
			} else {
				writer.WriteString("-1\n")
			}
		}
	}
}
```