← Home
For problem statement at 1000-1999/1400-1499/1420-1429/1427/problemA.txt this is a correct solution, but verifier at 1000-1999/1400-1499/1420-1429/1427/verifierA.go ends with case 1 failed
input:
4
4
-2 5 1 -3
5
3 -1 -4 -3 4
8
4 2 -3 -1 0 -2 2 1
8
-3 -2 -4 5 2 -1 2 -3
expected:
YES
5 1 -2 -3 
YES
-1 -4 -3 3 4 
YES
4 2 2 1 -3 -1 0 -2 
YES
-3 -2 -4 -1 -3 5 2 2
got:
YES
5 1 -2 -3
YES
-4 -3 -1 3 4
YES
4 2 2 1 0 -1 -2 -3
YES
-4 -3 -3 -2 -1 2 2 5

exit status 1 can you fix the verifier? ```go
package main

import (
	"fmt"
	"sort"
)

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int
		fmt.Scan(&n)
		a := make([]int, n)
		sum := 0
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			sum += a[i]
		}
		if sum == 0 {
			fmt.Println("NO")
			continue
		}
		if sum > 0 {
			sort.Sort(sort.Reverse(sort.IntSlice(a)))
		} else {
			sort.Ints(a)
		}
		curr := 0
		good := true
		for i := 0; i < n; i++ {
			curr += a[i]
			if curr == 0 {
				good = false
				break
			}
		}
		if !good {
			if sum > 0 {
				sort.Ints(a)
			} else {
				sort.Sort(sort.Reverse(sort.IntSlice(a)))
			}
			curr = 0
			good = true
			for i := 0; i < n; i++ {
				curr += a[i]
				if curr == 0 {
					good = false
					break
				}
			}
			if !good {
				fmt.Println("NO")
				continue
			}
		}
		fmt.Println("YES")
		for i := 0; i < n; i++ {
			if i > 0 {
				fmt.Print(" ")
			}
			fmt.Print(a[i])
		}
		fmt.Println()
	}
}
```