There are $$$n$$$ candies in a row, numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th of them has a repose $$$v_{i}$$$ and a color $$$c_{i}$$$.
Timulo wants to choose a subsequence of candies, such that adjacent candies in the chosen subsequence have different colors
Formally, if the indices of the candies that Timulo chose were $$$i_{1} \lt i_{2} \lt \dots \lt i_{k}$$$, then $$$c_{i_{j}} \neq c_{i_{j + 1}}$$$ for all $$$1 \leq j \leq k -1$$$.
Timulo wants to maximize the sum of the repose from the subsequence. Can you help him find the maximum possible sum?
A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.
The first line contains an integer $$$n (1 \leq n \leq 2 \cdot 10^5)$$$: The number of candies.
The second line contains $$$n$$$ integers $$$v_{1}, v_{2}, \dots, v_{n} \(0 \leq v_{i} \leq 10^9)$$$, denoting the repose of the candies.
The third line contains $$$n$$$ integers $$$c_{1}, c_{2}, \dots ,c_{n} \(1 \leq c_{i} \leq n)$$$, denoting the colors of the candies.
Print the maximum sum of the repose of any subsequence satisfying the condition mentioned.
44 3 5 32 2 1 1
9
| Name |
|---|


