Minimum subarray average
Time limit1sMemory limit512 MB
Find the starting index of a length-two-or-more subarray whose average is smallest, breaking ties by smallest start.
Problem
You are given an array of length whose indices start at 0. For two integers and with , the subarray average is defined as
so a subarray average is the average of two or more consecutive elements.
For example, if with , , , the possible subarray averages are , , and . The smallest of them is .
Given the array , find a pair whose subarray average is minimal and print . If several pairs reach the minimum, print the smallest .
Input
The first line contains the length of the array. The second line contains , , , separated by spaces.
Output
Print on the first line.
Hint
If , then there is an integer with such that
or