← Home
For problem statement at 1000-1999/1200-1299/1250-1259/1252/problemJ.txt this is a correct solution, but verifier at 1000-1999/1200-1299/1250-1259/1252/verifierJ.go ends with reference runtime error on test 1: exec: "refJ.bin": executable file not found in $PATH
exit status 1 can you fix the verifier? package main

import (
	"fmt"
)

func main() {
	var n, k, g1, g2, g3 int
	if _, err := fmt.Scan(&n, &k, &g1, &g2, &g3); err != nil {
		return
	}
	var yard string
	if _, err := fmt.Scan(&yard); err != nil {
		return
	}

	segments := make([]int, 0)
	currentSoil := 0
	for i := 0; i < n; i++ {
		if yard[i] == '.' {
			currentSoil++
		} else {
			segments = append(segments, currentSoil)
			currentSoil = 0
		}
	}
	segments = append(segments, currentSoil)
	m := len(segments) - 1

	maxT3 := 55
	maxO := 55

	reachable := make([][][]bool, 2)
	for i := range reachable {
		reachable[i] = make([][]bool, maxT3)
		for j := range reachable[i] {
			reachable[i][j] = make([]bool, maxO)
		}
	}
	reachable[0][0][0] = true

	for i := 0; i <= m; i++ {
		nextReachable := make([][][]bool, 2)
		for j := range nextReachable {
			nextReachable[j] = make([][]bool, maxT3)
			for kIdx := range nextReachable[j] {
				nextReachable[j][kIdx] = make([]bool, maxO)
			}
		}

		for left := 0; left < 2; left++ {
			for t3 := 0; t3 < maxT3; t3++ {
				for o := 0; o < maxO; o++ {
					if !reachable[left][t3][o] {
						continue
					}

					length := segments[i] - left
					if length < 0 {
						continue
					}

					if i == m {
						newO := o + (length % 2)
						if newO < maxO {
							nextReachable[0][t3][newO] = true
						}
					} else {
						newO := o + (length % 2)
						if newO < maxO {
							nextReachable[0][t3][newO] = true
						}

						if length >= 1 {
							newO2 := o + ((length - 1) % 2)
							if t3+1 < maxT3 && newO2 < maxO {
								nextReachable[1][t3+1][newO2] = true
							}
						}
					}
				}
			}
		}
		reachable = nextReachable
	}

	ans := 0
	totalSoil := 0
	for _, s := range segments {
		totalSoil += s
	}

	for t3 := 0; t3 < maxT3; t3++ {
		for o := 0; o < maxO; o++ {
			if !reachable[0][t3][o] {
				continue
			}

			sRem := totalSoil - 2*t3
			limit := k
			if limit > sRem {
				limit = sRem
			}

			dMax := (sRem - o) / 2

			cands := []int{
				0,
				o,
				o + 1,
				limit - 1,
				limit,
			}

			for _, c := range cands {
				if c < 0 || c > limit {
					continue
				}

				kVal := c - o
				if kVal < 0 {
					kVal = 0
				}

				d := dMax - (kVal+1)/2
				score := t3*g3 + c*g1 + d*g2

				if score > ans {
					ans = score
				}
			}
		}
	}

	fmt.Println(ans)
}