AtCoder Problemas Boot camp for Beginners Normal 3
問題
思考
><で挟まれている値は0になる<の右は左より1大きい>の左は右より1大きい- a[i]を0で初期化する
- 左から走査していき
<の場合は a[i+1] = a[i] + 1 - 右から走査し、
>の場合は a[i] = max(a[i], a[i+1] +1)
S = input() N = len(S) + 1 a = [0 for _ in range(N)] for i in range(N - 1): if S[i] == "<": a[i + 1] += a[i] + 1 for i in range(N - 2, -1, -1): if S[i] == ">": a[i] = max(a[i], a[i + 1] + 1) answer = sum(a) print(answer)