| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 9012 |
| 문제명 | 괄호 |
| 레벨 | 실버 4 |
| 분류 |
괄호문자열 |
| 시간복잡도 | O(T*n) |
| 인풋사이즈 | T<=?, n<=50 |
| 사용한 언어 | Python 3.13 |
| 제출기록 | 32412KB / 48ms |
| 최고기록 | 32ms |
| 해결날짜 | 2025/02/16 |
"""Solution code for "BOJ 9012. 괄호".
- Problem link: https://www.acmicpc.net/problem/9012
- Solution link: http://www.teferi.net/ps/problems/boj/9012
"""
from teflib import psutils
@psutils.run_n_times
def main():
S = input()
score = 0
min_score = min(score := score + (1 if x == '(' else -1) for x in S)
print('YES' if score == 0 and min_score >= 0 else 'NO')
if __name__ == '__main__':
main()