← Home
For problem statement at 0-999/100-199/130-139/130/problemH.txt this is a correct solution, but verifier at 0-999/100-199/130-139/130/verifierH.go ends with All tests passed can you fix the verifier? package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(in, &s)

	balance := 0
	for _, ch := range s {
		if ch == '(' {
			balance++
		} else {
			balance--
		}
		if balance < 0 {
			fmt.Println("NO")
			return
		}
	}

	if balance == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}