No.2924 <===Super Spaceship String===>
タグ : / 解いたユーザー数 156
作問者 :
tnodino
/ テスター :
mymelochan
👑
kusirakusira
Problem Statement
There is a string $S$, and $S$ consists only of <, >, and =.
A string satisfying the following condition is called a super spaceship string.
- It is the concatenation of 1 character
<, 1 or more characters=, and 1 character>, in this order.
For example, <=> and <====> are super spaceship strings, but >=<, <>, and <==<> are not.
You may perform the following operation any number of times: choose a substring of the string $S$ that is a super spaceship string, remove it, and concatenate the parts before and after it.
When the operations are performed appropriately, what is the minimum possible length of $S$?
Constraints
- $1 \le |S| \le 5 \times 10^5$
- The string $S$ consists only of
<,>, and=.
Input
$S$
Output
Output the answer.
Sample
Sample 1
Input
<=<<==>=><>
Output
4
For example, a length of 4 can be achieved by performing the operations as follows.
- Remove the 4 ~ 7th characters of
<=<<==>=><>, which gives<=<=><>. - Remove the 3 ~ 5th characters of
<=<=><>, which gives<=<>. - No operation can be performed on
<=<>.
No matter how the operations are performed, the string cannot become any shorter, so the answer is 4.
Sample 2
Input
>=<=<>=>=<
Output
10
There are also cases where no operation can be performed even once.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。