Preparando MOJI

Balanced brackets

2000ms 65536K

Description:

A sequence of brackets is called balanced if one can turn it into a valid math expression by adding characters «+» and «1». For example, sequences «(())()», «()» and «(()(()))» are balanced, while «)(», «(()» and «(()))(» are not.

You are given a string which consists of opening and closing round brackets. Check whether it is a balanced bracket sequence.

Input:

The only line of input contains a string between 1 and 100 characters long, inclusive. Each character in the string will be «(» or «)».

Output:

Output «YES» if the bracket sequence is balanced, and «NO» otherwise (quotes for clarity only).

Sample Input:

(()(()))()

Sample Output:

YES

Sample Input:

())()

Sample Output:

NO

Informação

Codeforces

Provedor Codeforces

Código CF130H

Tags

*special

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 08:33:41

Relacionados

Nada ainda