본문 바로가기

Programming [Python]/백준 알고리즘 솔루션

#240 백준 파이썬 [17389] 보너스 점수

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

 

Python Code

N = int(input())
S = str(input())
answer = 0
bonus = 0

for i in range(len(S)):
    if S[i] == 'O':
        answer += i + 1 + bonus
        bonus += 1
    else:
        bonus = 0 
        
print(answer)