You are given an array of elements. You need to find all the subarrays such that their average sum is greater than the average sum of the remaining array elements. You need to print the start and end index of each subarray in sorted order in a new line.
Notes:
Notes:
- A subarray which starts at position and ends at position comes before a subarray that starts at and ends at if or if but
- The array indexes are in the range to .
- The average sum of an empty array is 0.
Input
The first line contains an integer that denotes the total number of elements in the array.
The next line contains space separated integers that denote the elements of the array .
The first line contains an integer that denotes the total number of elements in the array.
The next line contains space separated integers that denote the elements of the array .
Output
The first line of output should contain an integer that denotes how many subarrays that follow the given criterion are there.
The next lines contain a pair of space-separated integers corresponding to the start and end positions of the valid subarrays.
The first line of output should contain an integer that denotes how many subarrays that follow the given criterion are there.
The next lines contain a pair of space-separated integers corresponding to the start and end positions of the valid subarrays.
Post a Comment