← Home
For problem statement at 1000-1999/1500-1599/1550-1559/1555/problemC.txt this is a correct solution, but verifier at 1000-1999/1500-1599/1550-1559/1555/verifierC.go ends with All tests passed can you fix the verifier? package main

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

type FastScanner struct {
	r *bufio.Reader
}

func (fs *FastScanner) NextInt() 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 max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func main() {
	fs := &FastScanner{r: bufio.NewReaderSize(os.Stdin, 1<<20)}
	out := bufio.NewWriterSize(os.Stdout, 1<<20)
	defer out.Flush()

	t := int(fs.NextInt())
	for ; t > 0; t-- {
		m := int(fs.NextInt())
		top := make([]int64, m)
		bottom := make([]int64, m)
		var totalTop int64
		for i := 0; i < m; i++ {
			top[i] = fs.NextInt()
			totalTop += top[i]
		}
		for i := 0; i < m; i++ {
			bottom[i] = fs.NextInt()
		}

		var prefixBottom int64
		topRemain := totalTop
		ans := int64(1 << 62)

		for i := 0; i < m; i++ {
			topRemain -= top[i]
			cur := max(topRemain, prefixBottom)
			if cur < ans {
				ans = cur
			}
			prefixBottom += bottom[i]
		}

		out.WriteString(strconv.FormatInt(ans, 10))
		out.WriteByte('\n')
	}
}