For problem statement at 1000-1999/1600-1699/1650-1659/1650/problemF.txt this is a correct solution, but verifier at 1000-1999/1600-1699/1650-1659/1650/verifierF.go ends with 2026/03/20 23:29:42 REFERENCE_SOURCE_PATH environment variable is not set
exit status 1 can you fix the verifier? package main
import (
"bufio"
"io"
"os"
"strconv"
)
var buf []byte
var bufPos int
func nextInt() int {
for bufPos < len(buf) && buf[bufPos] <= ' ' {
bufPos++
}
if bufPos >= len(buf) {
return 0
}
res := 0
sign := 1
if buf[bufPos] == '-' {
sign = -1
bufPos++
}
for bufPos < len(buf) && buf[bufPos] >= '0' && buf[bufPos] <= '9' {
res = res*10 + int(buf[bufPos]-'0')
bufPos++
}
return res * sign
}
func nextInt64() int64 {
for bufPos < len(buf) && buf[bufPos] <= ' ' {
bufPos++
}
if bufPos >= len(buf) {
return 0
}
var res int64 = 0
sign := int64(1)
if buf[bufPos] == '-' {
sign = -1
bufPos++
}
for bufPos < len(buf) && buf[bufPos] >= '0' && buf[bufPos] <= '9' {
res = res*10 + int64(buf[bufPos]-'0')
bufPos++
}
return res * sign
}
type Option struct {
id int
t int64
p int
}
func main() {
buf, _ = io.ReadAll(os.Stdin)
if len(buf) == 0 {
return
}
T := nextInt()
if T == 0 {
return
}
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
for t := 0; t < T; t++ {
n := nextInt()
m := nextInt()
a := make([]int64, n+1)
for i := 1; i <= n; i++ {
a[i] = nextInt64()
}
options := make([][]Option, n+1)
for i := 1; i <= m; i++ {
e := nextInt()
t_i := nextInt64()
p_i := nextInt()
options[e] = append(options[e], Option{id: i, t: t_i, p: p_i})
}
ans := make([]int, 0)
possible := true
var currentTime int64 = 0
for i := 1; i <= n; i++ {
taskOptions := options[i]
K := len(taskOptions)
dp := make([]int64, 101)
const INF int64 = 1e18
for j := 1; j <= 100; j++ {
dp[j] = INF
}
dp[0] = 0
parent := make([]int8, K*101)
for j := 0; j < K*101; j++ {
parent[j] = -1
}
for j := 0; j < K; j++ {
opt := taskOptions[j]
for w := 100; w >= 0; w-- {
if dp[w] != INF {
nw := w + opt.p
if nw > 100 {
nw = 100
}
if dp[w]+opt.t < dp[nw] {
dp[nw] = dp[w] + opt.t
parent[j*101+nw] = int8(w)
}
}
}
}
if dp[100] == INF {
possible = false
break
}
currentTime += dp[100]
if currentTime > a[i] {
possible = false
break
}
currW := 100
for j := K - 1; j >= 0; j-- {
p := parent[j*101+currW]
if p != -1 {
ans = append(ans, taskOptions[j].id)
currW = int(p)
}
}
}
if !possible {
out.WriteString("-1\n")
} else {
out.WriteString(strconv.Itoa(len(ans)))
out.WriteByte('\n')
for i, id := range ans {
if i > 0 {
out.WriteByte(' ')
}
out.WriteString(strconv.Itoa(id))
}
out.WriteByte('\n')
}
}
}