For problem statement at 1000-1999/1600-1699/1670-1679/1674/problemE.txt this is a correct solution, but verifier at 1000-1999/1600-1699/1670-1679/1674/verifierE.go ends with wrong answer on test 1
input:
1
5
12 21 22 30 18
expected: 11
got: 1152921504606846976
exit status 1 can you fix the verifier? package main
import (
"bufio"
"fmt"
"io"
"os"
)
func ceilDiv(x, y int) int {
return (x + y - 1) / y
}
func main() {
data, _ := io.ReadAll(os.Stdin)
idx := 0
nextInt := func() int {
for idx < len(data) && (data[idx] < '0' || data[idx] > '9') {
idx++
}
val := 0
for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
val = val*10 + int(data[idx]-'0')
idx++
}
return val
}
n := nextInt()
a := make([]int, n)
for i := 0; i < n; i++ {
a[i] = nextInt()
}
ans := 1 << 60
for i := 0; i+1 < n; i++ {
t := ceilDiv(a[i], 2)
if v := ceilDiv(a[i+1], 2); v > t {
t = v
}
if v := ceilDiv(a[i]+a[i+1], 3); v > t {
t = v
}
if t < ans {
ans = t
}
}
for i := 0; i+2 < n; i++ {
t := ceilDiv(a[i]+a[i+2], 2)
if t < ans {
ans = t
}
}
c := make([]int, n)
for i := 0; i < n; i++ {
c[i] = ceilDiv(a[i], 2)
}
pref := make([]int, n)
if n > 0 {
pref[0] = c[0]
for i := 1; i < n; i++ {
pref[i] = pref[i-1]
if c[i] < pref[i] {
pref[i] = c[i]
}
}
}
for j := 3; j < n; j++ {
t := pref[j-3] + c[j]
if t < ans {
ans = t
}
}
out := bufio.NewWriter(os.Stdout)
fmt.Fprintln(out, ans)
out.Flush()
}