목차

괄호 끼워넣기

ps
링크acmicpc.net/…
출처BOJ
문제 번호11899
문제명괄호 끼워넣기
레벨실버 3
분류

괄호문자열

시간복잡도O(n)
인풋사이즈n<=50
사용한 언어Python 3.13
제출기록32412KB / 40ms
최고기록32ms
해결날짜2025/02/16

풀이

코드

"""Solution code for "BOJ 11899. 괄호 끼워넣기".

- Problem link: https://www.acmicpc.net/problem/11899
- Solution link: http://www.teferi.net/ps/problems/boj/11899
"""


def main():
    S = input()

    score = 0
    min_score = min(score := score + (1 if x == '(' else -1) for x in S)

    print(score - 2 * min(0, min_score))


if __name__ == '__main__':
    main()