Redirecting to
NADOS

Maximum Sum Of Three Non-overlapping Subarrays

1. You are given an array(arr) of positive numbers and a number K.
2. You have to find the maximum sum of elements in three non-overlapping subarrays.
3. Also, you have to print indices representing the starting position of every subarray.
4. If there are multiple answers, print the lexicographically smallest one.
Input Format
A number N
arr1
arr2.. N numbers
A number K
Output Format
4 space-separated numbers, where first number represents the maximum sum of three non-overlapping subarrays and rest three represents the starting position of every subarray.
Question Video
Constraints
1 <= N <= 20000
1 <= arr[i] <= 10^5
1 <= K <= N/3
Sample Input
8
1 2 1 2 6 7 5 1
2
Sample Output
23 0 3 5 


  • Asked in Companies
  • Related Topics






Video Solution

Code Solution

Run
 
Run
Id Name