|
||||||||||
Subsequence ProblemTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 297 Accepted Submission(s): 95 Special Judge Problem Description You must be very familiar with the classic maximum subsequence problem: Given an integer sequence A1, A2, ..., An, Find a continuous subsequence A[i..j] with maximum sum: Ai + Ai+1 + ... + Aj. (1 <= i <= j <= n) As a talented ACMer, you can solve this problem in seconds. So here comes a harder version: Given an integer sequence A1, A2, ..., An, Find a continuous subsequence A[i..j] with maximum average value: (Ai + Ai+1 + ... + Aj) / (j - i + 1). (1 <= i <= j <= n) As a talented ACMer, you can solve this problem in minutes. So here comes a more harder version: Given an integer sequence A1, A2, ..., An, Find a continuous subsequence A[i..j] with maximum squared average value: (Ai + Ai+1 + ... + Aj)^2 / (j - i + 1). (1 <= i <= j <= n) As a talented ACMer, can you solve this problem? Input The first line of each test case contains one integer n (1 <= n <= 100,000), the length of the original sequence. The next line contains n integers A1, A2, ..., An. (-1,000 <= Ai <= 1,000) Output Output one real number for each test case, indicating the max squared average value described above. You will get accepted if the difference between your answer and standard answer is no more than 10-4. Sample Input
Sample Output
Author TJU Source | ||||||||||
|