← Home
For problem statement at 1000-1999/1800-1899/1800-1809/1804/problemB.txt this is a correct solution, but verifier at 1000-1999/1800-1899/1800-1809/1804/verifierB.go ends with All tests passed can you fix the verifier? package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

type FastScanner struct {
	r *bufio.Reader
}

func NewFastScanner() *FastScanner {
	return &FastScanner{r: bufio.NewReaderSize(os.Stdin, 1<<20)}
}

func (fs *FastScanner) NextInt() int {
	sign, val := 1, 0
	c, err := fs.r.ReadByte()
	for (c < '0' || c > '9') && c != '-' {
		c, err = fs.r.ReadByte()
		if err != nil {
			return 0
		}
	}
	if c == '-' {
		sign = -1
		c, _ = fs.r.ReadByte()
	}
	for c >= '0' && c <= '9' {
		val = val*10 + int(c-'0')
		c, err = fs.r.ReadByte()
		if err != nil {
			break
		}
	}
	if err == nil {
		_ = fs.r.UnreadByte()
	}
	return sign * val
}

func main() {
	fs := NewFastScanner()
	T := fs.NextInt()
	var out bytes.Buffer

	for ; T > 0; T-- {
		n := fs.NextInt()
		k := fs.NextInt()
		d := fs.NextInt()
		w := fs.NextInt()

		times := make([]int, n)
		for i := 0; i < n; i++ {
			times[i] = fs.NextInt()
		}

		ans := 0
		i := 0
		for i < n {
			ans++
			limit := times[i] + w + d
			used := 0
			for i < n && used < k && times[i] <= limit {
				i++
				used++
			}
		}

		fmt.Fprintln(&out, ans)
	}

	fmt.Print(out.String())
}