Maximum Possible Sum

easy
1.Given two arrays A and B of equal number of elements. 2.The task is to find the maximum sum possible of a window in array B such that elements of same window in array A are unique. 3.You have to complete the function printMaxSum() to print maximum possible sum

Input Format

1.First line starts with an integer N denoting the size of the arrays A and B. 2.Second line of input contains N space separated integers Of array A. 3.And third line of input contains N space separated integers Of array B.

Output Format

Print the maximum possible sum

Constraints

1<=N<=10^4
 0<=A[i]<=10^6
 0<=B[i]<=10^6

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
7
0 1 2 3 0 1 4 
9 8 1 2 3 4 5
Output
20
Previous
Maximum Number Of Characters Between Any Two Same Characters
Next
Maximum Size Subarray Sum Equals K

Related Questions