← 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"
	"io"
	"os"
	"strconv"
)

func main() {
	data, _ := io.ReadAll(os.Stdin)
	idx := 0
	nextInt := func() int {
		for idx < len(data) && data[idx] <= ' ' {
			idx++
		}
		num := 0
		for idx < len(data) && data[idx] > ' ' {
			num = num*10 + int(data[idx]-'0')
			idx++
		}
		return num
	}

	m := nextInt()
	n := nextInt()

	dp := make([]int64, n+1)
	out := make([]byte, 0, m*12)

	for i := 0; i < m; i++ {
		for j := 1; j <= n; j++ {
			t := int64(nextInt())
			if dp[j] < dp[j-1] {
				dp[j] = dp[j-1]
			}
			dp[j] += t
		}
		out = strconv.AppendInt(out, dp[n], 10)
		if i+1 < m {
			out = append(out, ' ')
		}
	}

	w := bufio.NewWriterSize(os.Stdout, len(out)+1)
	w.Write(out)
	w.Flush()
}