CF1107E Vasya and Binary String

Description

Vasya has a string $ s $ of length $ n $ consisting only of digits 0 and 1. Also he has an array $ a $ of length $ n $ . Vasya performs the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from the string and glue together the remaining parts (any of them can be empty). For example, if he erases substring 111 from string 111110 he will get the string 110. Vasya gets $ a_x $ points for erasing substring of length $ x $ . Vasya wants to maximize his total points, so help him with this!

Input Format

N/A

Output Format

N/A

Explanation/Hint

In the first example the optimal sequence of erasings is: 1101001 $ \rightarrow $ 111001 $ \rightarrow $ 11101 $ \rightarrow $ 1111 $ \rightarrow $ $ \varnothing $ . In the second example the optimal sequence of erasings is: 10101 $ \rightarrow $ 1001 $ \rightarrow $ 11 $ \rightarrow $ $ \varnothing $ .