← Home
For problem statement at 1000-1999/1100-1199/1110-1119/1119/problemE.txt this is a correct solution, but verifier at 1000-1999/1100-1199/1110-1119/1119/verifierE.go ends with All tests passed can you fix the verifier? package main

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

type FastScanner struct {
	r *bufio.Reader
}

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

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

func main() {
	in := NewFastScanner()
	n := int(in.NextInt64())
	var sum int64
	var ans int64
	for i := 0; i < n; i++ {
		x := in.NextInt64()
		sum += x
		byPairs := ans + x/2
		byTotal := sum / 3
		if byPairs < byTotal {
			ans = byPairs
		} else {
			ans = byTotal
		}
	}
	fmt.Println(ans)
}