← Home
For problem statement at 0-999/400-499/410-419/416/problemB.txt this is a correct solution, but verifier at 0-999/400-499/410-419/416/verifierB.go ends with All tests passed can you fix the verifier? package main

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

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, _ := 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 + int(c-'0')
		c2, err := fs.r.ReadByte()
		if err != nil {
			break
		}
		c = c2
		if c < '0' || c > '9' {
			break
		}
	}
	return sign * val
}

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

func main() {
	in := NewFastScanner()
	m := in.NextInt()
	n := in.NextInt()

	dp := make([]int, n)
	out := bufio.NewWriterSize(os.Stdout, 1<<20)
	defer out.Flush()

	for i := 0; i < m; i++ {
		for j := 0; j < n; j++ {
			t := in.NextInt()
			if j == 0 {
				dp[j] += t
			} else {
				dp[j] = max(dp[j], dp[j-1]) + t
			}
		}
		if i > 0 {
			out.WriteByte(' ')
		}
		out.WriteString(strconv.Itoa(dp[n-1]))
	}
	fmt.Fprintln(out)
}