← Home
For problem statement at 0-999/100-199/180-189/180/problemE.txt this is a correct solution, but verifier at 0-999/100-199/180-189/180/verifierE.go ends with All tests passed can you fix the verifier? ```go
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	var group_color, group_len []int
	if n > 0 {
		prev := a[0]
		cnt := 1
		for i := 1; i < n; i++ {
			if a[i] != prev {
				group_color = append(group_color, prev)
				group_len = append(group_len, cnt)
				prev = a[i]
				cnt = 1
			} else {
				cnt++
			}
		}
		group_color = append(group_color, prev)
		group_len = append(group_len, cnt)
	}
	p := len(group_len)
	prefix := make([]int64, p+1)
	for i := 1; i <= p; i++ {
		prefix[i] = prefix[i-1] + int64(group_len[i-1])
	}
	color_runs := make([][]int, m+1)
	for i := 0; i < p; i++ {
		c := group_color[i]
		color_runs[c] = append(color_runs[c], i)
	}
	ans := 0
	for c := 1; c <= m; c++ {
		idx := color_runs[c]
		s := len(idx)
		if s == 0 {
			continue
		}
		lens := make([]int, s)
		for t := 0; t < s; t++ {
			lens[t] = group_len[idx[t]]
		}
		gaps := make([]int, s-1)
		for t := 0; t < s-1; t++ {
			st := idx[t] + 1
			en := idx[t+1]
			gaps[t] = int(prefix[en] - prefix[st])
		}
		max_for_c := 0
		curr_sum := 0
		curr_cost := 0
		left := 0
		for right := 0; right < s; right++ {
			curr_sum += lens[right]
			if right > 0 {
				curr_cost += gaps[right-1]
			}
			for curr_cost > k && left <= right {
				curr_sum -= lens[left]
				if left < right {
					curr_cost -= gaps[left]
				}
				left++
			}
			if curr_sum > max_for_c {
				max_for_c = curr_sum
			}
		}
		if max_for_c > ans {
			ans = max_for_c
		}
	}
	fmt.Println(ans)
}
```