#C11702. Maximum Weighted Subarray Sum
Maximum Weighted Subarray Sum
Maximum Weighted Subarray Sum
Given two arrays A and B each containing n integers, your task is to find a contiguous subarray for which the weighted sum is maximized.
The weighted sum of a subarray from index i to j is defined as:
$$S = \sum_{k=i}^{j} A[k] \times B[k]$$
You are required to output the maximum weighted sum over all possible contiguous subarrays.
inputFormat
The input consists of three lines:
- The first line contains an integer n, the length of the arrays.
- The second line contains n space-separated integers representing the array A.
- The third line contains n space-separated integers representing the array B.
outputFormat
Output a single integer — the maximum weighted sum over all contiguous subarrays.
## sample5
1 2 3 4 5
5 4 3 2 1
35
</p>