ALGO ARTIS プログラミングコンテスト2023 秋 (AtCoder Regular Contest 168)
翻译中…
Problem Statement
翻译中…
You are given a string $S$ of length $N-1$ consisting of < and >.
翻译中…
A sequence $x=(x_1,x_2,\cdots,x_N)$ of length $N$ is called a good sequence if and only if it satisfies the following condition:
翻译中…
- For each
$i$($1 \leq i \leq N-1$), if the$i$-th character of$S$is<, then$x_i\lt x_{i+1}$; if it is>, then$x_i \gt x_{i+1}$.
翻译中…
Find the minimum possible inversion number of a good sequence.
翻译中…
What is the inversion number of a sequence? The inversion number of a sequence $x=(x_1,x_2,\cdots,x_n)$ of length $n$ is the number of pairs of integers $(i,j)$ ($1 \leq i < j \leq n$) such that $x_i>x_j$.
翻译中…
Constraints
翻译中…
$2 \leq N \leq 250000$$S$is a string of length$N-1$consisting of<and>.- All input values are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
S
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
4
<><
Output #1
1
$x=(1,2,1,2)$ is a good sequence, and its inversion number is $1$. There is no good sequence whose inversion number is $0$, so the answer is $1$.
Input #2
2
<
Output #2
0
Input #3
10
>>>>>>>>>
Output #3
45
Input #4
30
<<><>>><><>><><><<>><<<><><<>
Output #4
19
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。