AmazonOA #207
Get Max Skill Sum
估计中等可在线判题
Employees are arranged by index, and each expertise is 0 or 1. Choose a contiguous range in which the two types have equal counts, and maximize the total skill. Choosing nobody is allowed and gives 0.
输入格式
The first line contains n, the second line n skill values, and the third line n 0/1 expertise flags. This site uses 1≤n≤200000, −10^9≤skill≤10^9.
输出格式
Output a single integer, the answer.
样例 1
输入:
3
2 3 5
0 1 1
输出:
5
样例 2
输入:
4
-5 -5 8 9
0 1 0 1
输出:
17
样例 3
输入:
2
-1 -2
0 1
输出:
0
样例说明
The answers are 5, 17 and 0.