← Home
For problem statement at 0-999/600-699/600-609/604/problemB.txt this is a correct solution, but verifier at 0-999/600-699/600-609/604/verifierB.go ends with case 2 failed: expected 5 got 7
input:3 2
2 3 5
exit status 1 can you fix the verifier? package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1<<20)

func nextInt() int {
	sign := 1
	x := 0
	c, _ := rdr.ReadByte()
	for (c < '0' || c > '9') && c != '-' {
		c, _ = rdr.ReadByte()
	}
	if c == '-' {
		sign = -1
		c, _ = rdr.ReadByte()
	}
	for c >= '0' && c <= '9' {
		x = x*10 + int(c-'0')
		c, _ = rdr.ReadByte()
	}
	return x * sign
}

func main() {
	n := nextInt()
	k := nextInt()
	s := make([]int, n)
	for i := 0; i < n; i++ {
		s[i] = nextInt()
	}

	if n <= k {
		fmt.Println(s[n-1])
		return
	}

	p := n - k
	ans := 0
	for i := 0; i < p; i++ {
		sum := s[i] + s[n-1-i]
		if sum > ans {
			ans = sum
		}
	}
	for i := p; i <= n-p-1; i++ {
		if s[i] > ans {
			ans = s[i]
		}
	}
	fmt.Println(ans)
}