题目描述
Problem Description
Takahashi has built a racing track for penguins.
The racing track consists of $ N $ squares arranged in a single row from west to east.
The states of these squares are represented by a string $ S $, where the $ i $-th square from the west is "snow" if the $ i $-th character of $ S $ is -, and "ice" if it is >.
The starting point is the west end of the westernmost square, and the goal is the east end of the easternmost square.
Takahashi's penguin will move eastward from the starting point towards the goal.
The penguin takes $ 1 $ second to pass through a snow square and $ 1/(k+2) $ seconds to pass through an ice square.
Here, $ k $ is the number of consecutive ice squares immediately preceding that ice square.
For example, if there are two ice squares immediately following a snow square, the first ice square takes $ 1/2 $ second and the second ice square takes $ 1/3 $ second to pass through.
Before the penguin starts, Takahashi can change one snow square to an ice square.
What is the minimum time required for the penguin to reach the goal from the starting point?
Input Format
The input is given from the standard input in the following format:
$ N $ $ S $
Output Format
Output the minimum number of seconds required for the penguin to reach the goal.
The answer will be considered correct if the relative or absolute error is at most $ 10^{-8} $.
Sample Input and Output
Sample Input #1
5
-->--
Sample Output #1
3.83333333333333
Sample Input #2
7
-------
Sample Output #2
6.5
Sample Input #3
10
-->>>-->--
Sample Output #3
6.78333333333333
Notes/Hints
Constraints
- $3 \leq N \leq 100,000$
- $ S $ is a string of length $ N $ consisting of
-and> - $ S_1 = S_2 = S_{N-1} = S_N = $
- - In $ S $,
-always appears adjacent to another-
Sample Explanation 1
Changing the 4th square from the west from a snow square to an ice square results in the track -->>-. In this case, the penguin takes $ 1, 1, 1/2, 1/3, 1 $ seconds respectively to pass through the 1st, 2nd, 3rd, 4th, and 5th squares from the west, totaling $ 23/6 = 3.83333333... $ seconds, which is the shortest time.
Sample Explanation 2
Regardless of which square is changed from a snow square to an ice square, the penguin will reach the goal in $ 13/2 = 6.5 $ seconds.
Sample Explanation 3
Changing the 2nd or 6th square from the west from a snow square to an ice square allows the penguin to reach the goal in $ 407/60 = 6.783333333... $ seconds.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分