F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Subsequence Problem

Time 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
3 1 5 4 3 3 5 4
 

Sample Output
40.500000 48.000000
 

Author
TJU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 05:09:25, Gzip enabled