For problem statement at 1000-1999/1600-1699/1650-1659/1657/problemD.txt this is a correct solution, but verifier at 1000-1999/1600-1699/1650-1659/1657/verifierD.go ends with All tests passed can you fix the verifier? package main
import (
"bufio"
"io"
"os"
)
type Scanner struct {
buf []byte
pos int
}
func NewScanner() *Scanner {
b, _ := io.ReadAll(os.Stdin)
return &Scanner{buf: b, pos: 0}
}
func (s *Scanner) nextInt() int {
for s.pos < len(s.buf) && s.buf[s.pos] <= ' ' {
s.pos++
}
if s.pos >= len(s.buf) {
return 0
}
res := 0
for s.pos < len(s.buf) && s.buf[s.pos] > ' ' {
res = res*10 + int(s.buf[s.pos]-'0')
s.pos++
}
return res
}
func (s *Scanner) nextInt64() int64 {
for s.pos < len(s.buf) && s.buf[s.pos] <= ' ' {
s.pos++
}
if s.pos >= len(s.buf) {
return 0
}
res := int64(0)
for s.pos < len(s.buf) && s.buf[s.pos] > ' ' {
res = res*10 + int64(s.buf[s.pos]-'0')
s.pos++
}
return res
}
func printInt(out *bufio.Writer, x int) {
if x < 0 {
out.WriteByte('-')
x = -x
}
if x == 0 {
out.WriteByte('0')
return
}
var buf [20]byte
i := 19
for x > 0 {
buf[i] = byte(x%10 + '0')
i--
x /= 10
}
out.Write(buf[i+1:])
}
func main() {
in := NewScanner()
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
n := in.nextInt()
C := in.nextInt()
best := make([]int64, C+1)
for i := 0; i < n; i++ {
c := in.nextInt()
d := in.nextInt64()
h := in.nextInt64()
if d*h > best[c] {
best[c] = d * h
}
}
max_power := make([]int64, C+1)
for c := 1; c <= C; c++ {
if best[c] > 0 {
for k, x := int64(1), c; x <= C; k, x = k+1, x+c {
if k*best[c] > max_power[x] {
max_power[x] = k * best[c]
}
}
}
}
for x := 1; x <= C; x++ {
if max_power[x-1] > max_power[x] {
max_power[x] = max_power[x-1]
}
}
m := in.nextInt()
for j := 0; j < m; j++ {
D := in.nextInt64()
H := in.nextInt64()
target := D * H
if max_power[C] <= target {
printInt(out, -1)
out.WriteByte(' ')
} else {
l, r := 1, C
ans := -1
for l <= r {
mid := l + (r-l)/2
if max_power[mid] > target {
ans = mid
r = mid - 1
} else {
l = mid + 1
}
}
printInt(out, ans)
out.WriteByte(' ')
}
}
out.WriteByte('\n')
}