For problem statement at 0-999/200-299/290-299/294/problemB.txt this is a correct solution, but verifier at 0-999/200-299/290-299/294/verifierB.go ends with test 2 failed
input:
5
2 6
2 5
1 7
1 5
1 3
expected:
5
got:
6
exit status 1 can you fix the verifier? ```go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
in := bufio.NewReader(os.Stdin)
var n int
fmt.Fscan(in, &n)
w1 := make([]int, 0)
w2 := make([]int, 0)
totalW := 0
for i := 0; i < n; i++ {
var t, w int
fmt.Fscan(in, &t, &w)
totalW += w
if t == 1 {
w1 = append(w1, w)
} else {
w2 = append(w2, w)
}
}
negInf := -1 << 30
dp := make([]int, totalW+1)
for i := range dp {
dp[i] = negInf
}
dp[0] = 0
for _, w := range w1 {
ndp := make([]int, totalW+1)
copy(ndp, dp)
for sw := 0; sw+w <= totalW; sw++ {
if dp[sw] == negInf {
continue
}
if dp[sw]+1 > ndp[sw+w] {
ndp[sw+w] = dp[sw] + 1
}
}
dp = ndp
}
for _, w := range w2 {
ndp := make([]int, totalW+1)
copy(ndp, dp)
for sw := 0; sw+w <= totalW; sw++ {
if dp[sw] == negInf {
continue
}
if dp[sw]+2 > ndp[sw+w] {
ndp[sw+w] = dp[sw] + 2
}
}
dp = ndp
}
ans := 1 << 30
for sv := 0; sv <= totalW; sv++ {
tv := dp[sv]
if tv == negInf {
continue
}
hw := totalW - sv
if hw <= tv && tv < ans {
ans = tv
}
}
fmt.Print(ans)
}
```