BOJ - 5874 - 큰소를 찾아라

Updated:

import sys

def solution():
    S = sys.stdin.readline().strip()
    ans = 0
    count = 0

    for i in range(1, len(S)):
        if S[i-1] ==')' and S[i] == ')': ans += count
        elif S[i-1] == '(' and S[i] == '(': count += 1
    
    print(ans)

solution()

https://www.acmicpc.net/problem/5874

Categories:

Updated:

Leave a comment