For problem statement at 1000-1999/1700-1799/1730-1739/1735/problemF.txt this is a correct solution, but verifier at 1000-1999/1700-1799/1730-1739/1735/verifierF.go ends with wrong answer on case 2
input:
1
4 698630094 455477953
405605459 78983182 982241255 331804768
579831916 646492070 877878548 603091695
expected:
1017247160.5895966291 1089042989.7067637444 1758645191.0051465034 1811774839.8306384087
got:
1017247160.5895966291 1017247160.5895967484 1837628373.0051465034 1837628373.0051465034
exit status 1 can you fix the verifier? ```go
package main
import (
"io"
"os"
"strconv"
)
type FastInput struct {
data []byte
idx int
n int
}
func (in *FastInput) nextInt64() int64 {
for in.idx < in.n && in.data[in.idx] <= ' ' {
in.idx++
}
var sign int64 = 1
if in.data[in.idx] == '-' {
sign = -1
in.idx++
}
var v int64
for in.idx < in.n {
c := in.data[in.idx]
if c < '0' || c > '9' {
break
}
v = v*10 + int64(c-'0')
in.idx++
}
return v * sign
}
type Node struct {
p, q int64
alpha float64
len, wt float64
sumLen, sumWt float64
prio uint32
left, right *Node
}
var (
pool []Node
poolPtr int
seed uint64 = 88172645463393265
)
func nextRand() uint32 {
seed ^= seed << 7
seed ^= seed >> 9
return uint32(seed)
}
func cmp(ap, aq, bp, bq int64) int {
l := ap * bq
r := bp * aq
if l < r {
return -1
}
if l > r {
return 1
}
return 0
}
func pull(t *Node) {
if t == nil {
return
}
t.sumLen = t.len
t.sumWt = t.wt
if t.left != nil {
t.sumLen += t.left.sumLen
t.sumWt += t.left.sumWt
}
if t.right != nil {
t.sumLen += t.right.sumLen
t.sumWt += t.right.sumWt
}
}
func newNode(p, q int64, addLen, addWt float64) *Node {
n := &pool[poolPtr]
poolPtr++
*n = Node{
p: p,
q: q,
alpha: float64(p) / float64(q),
len: addLen,
wt: addWt,
sumLen: addLen,
sumWt: addWt,
prio: nextRand(),
}
return n
}
func merge(a, b *Node) *Node {
if a == nil {
return b
}
if b == nil {
return a
}
if a.prio > b.prio {
a.right = merge(a.right, b)
pull(a)
return a
}
b.left = merge(a, b.left)
pull(b)
return b
}
func splitLT(t *Node, p, q int64) (*Node, *Node) {
if t == nil {
return nil, nil
}
if cmp(t.p, t.q, p, q) < 0 {
a, b := splitLT(t.right, p, q)
t.right = a
pull(t)
return t, b
}
a, b := splitLT(t.left, p, q)
t.left = b
pull(t)
return a, t
}
func splitLE(t *Node, p, q int64) (*Node, *Node) {
if t == nil {
return nil, nil
}
if cmp(t.p, t.q, p, q) <= 0 {
a, b := splitLE(t.right, p, q)
t.right = a
pull(t)
return t, b
}
a, b := splitLE(t.left, p, q)
t.left = b
pull(t)
return a, t
}
func insert(t *Node, p, q int64, addLen, addWt float64) *Node {
a, b := splitLT(t, p, q)
c, d := splitLE(b, p, q)
if c == nil {
c = newNode(p, q, addLen, addWt)
} else {
c.len += addLen
c.wt += addWt
pull(c)
}
return merge(merge(a, c), d)
}
func trimLeftLen(t *Node, d float64) (*Node, float64) {
if t == nil || d <= 0 {
return t, 0
}
leftLen := 0.0
leftWt := 0.0
if t.left != nil {
leftLen = t.left.sumLen
leftWt = t.left.sumWt
}
if d < leftLen {
var rem float64
t.left, rem = trimLeftLen(t.left, d)
pull(t)
return t, rem
}
rem := leftWt
d -= leftLen
t.left = nil
if d < t.len {
rm := t.alpha * d
if rm > t.wt {
rm = t.wt
}
t.len -= d
if t.len < 0 {
t.len = 0
}
t.wt -= rm
if t.wt < 0 {
t.wt = 0
}
if t.len == 0 {
return t.right, rem + rm
}
pull(t)
return t, rem + rm
}
rem += t.wt
d -= t.len
return trimLeftLen(t.right, d)
}
func trimRightWeight(t *Node, w float64) *Node {
if t == nil || w <= 0 {
return t
}
rightWt := 0.0
if t.right != nil {
rightWt = t.right.sumWt
}
if w < rightWt {
t.right = trimRightWeight(t.right, w)
pull(t)
return t
}
w -= rightWt
t.right = nil
if w < t.wt {
cut := w / t.alpha
if cut > t.len {
cut = t.len
}
t.len -= cut
if t.len < 0 {
t.len = 0
}
if w > t.wt {
w = t.wt
}
t.wt -= w
if t.wt < 0 {
t.wt = 0
}
if t.len == 0 {
return t.left
}
pull(t)
return t
}
w -= t.wt
return trimRightWeight(t.left, w)
}
func main() {
data, _ := io.ReadAll(os.Stdin)
in := FastInput{data: data, n: len(data)}
t := int(in.nextInt64())
pool = make([]Node, 300005)
out := make([]byte, 0, 1<<22)
for ; t > 0; t-- {
poolPtr = 0
n := int(in.nextInt64())
a := in.nextInt64()
b := in.nextInt64()
ps := make([]int64, n)
qs := make([]int64, n)
for i := 0; i < n; i++ {
ps[i] = in.nextInt64()
}
for i := 0; i < n; i++ {
qs[i] = in.nextInt64()
}
var root *Node
x := float64(a)
l := b
for i := 0; i < n; i++ {
p := ps[i]
q := qs[i]
x += float64(p)
l -= q
root = insert(root, p, q, 2*float64(q), 2*float64(p))
if l < 0 {
var removed float64
root, removed = trimLeftLen(root, float64(-l))
x -= removed
l = 0
}
if root != nil && root.sumWt > x {
root = trimRightWeight(root, root.sumWt-x)
}
if x < 0 {
x = 0
}
out = strconv.AppendFloat(out, x, 'f', 10, 64)
if i+1 == n {
out = append(out, '\n')
} else {
out = append(out, ' ')
}
}
}
os.Stdout.Write(out)
}
```