Company: Adobe
Difficulty: medium
Get Them All You are given an integer array of length `n` and three integers `x`, `y`, and `z`. Choose any number of non-overlapping contiguous subarrays. You may choose at most `x` subarrays of length 1, at most `y` subarrays of length 2, and at most `z` subarrays of length 3. No array index may belong to more than one chosen subarray. The score is the sum of all elements in the chosen subarrays. Find the maximum possible score. You may choose no subarray, in which case the score is 0. Input Format The first line contains an integer `n`. The second line contains `n` space-separated integers, the elements of the array. The third line contains three integers `x`, `y`, and `z`. Output Format Print one integer: the maximum possible score. Constraints `1 <= n <= 200` `-100000 <= arr[i] <= 100000` `0 <= x, y, z <= 20` The answer fits in a signed 64-bit integer. Examples ### Example 1 Input: `5` `1 2 3 4 5` `1 1 1` Output: `15` Explanation: choose `[1, 2]` and `[3, 4, 5]`.