Peter is a Star Wars nerd, and has plastic lightsabers with various amounts of strength that he bought to play with his friends. Unfortunately, Peter has no real life friends, and now needs to find something to do with his lightsabers.
Peter decides that he will put his lightsabers on display for all to see. However, Peter is very picky about how this design must look. Specifically, there must be between and lightsabers put on display, and any two adjacent lightsabers must have different colors. Since Peter is lazy, he wants to be as efficient as possible with this process, and as such, the lightsabers must be left in the relative order they are originally in.
Peter wants to flex on his friends (wait...), so he wants you find him the maximum sum of strength values for his lightsabers on display.
Input Specification
The first line will contain integers, .
The next line will contain integers , the strength of the lightsaber.
The final line will contain integers , the colour of the lightsaber.
Output Specification
One line, the maximum sum of strength values for Peter's display.
Subtasks
Subtask 1 [10%]
Subtask 2 [20%]
Subtask 3 [30%]
Subtask 4 [40%]
Sample Input 1
4 2 3
-1 3 4 -5
1 2 2 3
Sample Output 1
3
Comments