← Home
For problem statement at 0-999/300-399/350-359/356/problemC.txt this is a correct solution, but verifier at 0-999/300-399/350-359/356/verifierC.go ends with All tests passed can you fix the verifier? ```go
package main

import (
	"fmt"
	"io"
	"os"
)

func nextInt(data []byte, idx *int) int {
	n := len(data)
	for *idx < n && (data[*idx] < '0' || data[*idx] > '9') {
		(*idx)++
	}
	val := 0
	for *idx < n && data[*idx] >= '0' && data[*idx] <= '9' {
		val = val*10 + int(data[*idx]-'0')
		(*idx)++
	}
	return val
}

func baseRet(m int, c [5]int) int {
	c34 := c[3] + c[4]
	if m <= c34 {
		return 3 * m
	}
	ret := 3 * c34
	m -= c34
	if m <= c[2] {
		return ret + 2*m
	}
	ret += 2 * c[2]
	m -= c[2]
	if m <= c[1] {
		return ret + m
	}
	return ret + c[1]
}

func main() {
	data, _ := io.ReadAll(os.Stdin)
	idx := 0
	n := nextInt(data, &idx)

	var c [5]int
	t := 0
	for i := 0; i < n; i++ {
		a := nextInt(data, &idx)
		c[a]++
		t += a
	}

	lo := (t + 3) / 4
	hi := t / 3
	if hi > n {
		hi = n
	}
	if lo > hi {
		fmt.Print(-1)
		return
	}

	best := -1
	for m := lo; m <= hi; m++ {
		ret := baseRet(m, c)
		extra := t - 3*m
		if extra > c[4] {
			extra = c[4]
		}
		ret += extra
		if ret > best {
			best = ret
		}
	}

	fmt.Print(t - best)
}
```