<Inversion>

AtCoder
IDarc168_a
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
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
API Response (JSON)
{
  "problem": {
    "name": "<Inversion>",
    "description": {
      "content": "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 conditio",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc168_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a string $S$ of length $N-1$ consisting of `<` and `>`.\nA 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 conditio...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments