V-Diagram

시간 제한1초메모리 제한2048 MB

요약
V자 모양 수열이 주어질 때, 길이가 3 이상인 연속한 V자 모양 부분수열 중 평균이 최대인 것을 찾아 그 평균을 출력한다.
난이도

보통10점 중 7점

유형
배열, 그리디, 수학, 완전 탐색
정답자
아직 제출이 없습니다

문제

A 11-indexed integer sequence aa of length nn is a V-diagram if n≥3n\ge 3 and there exists an index ii (1<i<n1< i< n) satisfying:

  • a_j>a_j+1a\_j>a\_{j+1} for 1≤j\<i1\le j\<i;
  • a_j>a_j−1a\_j>a\_{j-1} for i\<j≤ni\<j\le n.

Given a V-diagram aa, find a V-diagram bb with maximum average, satisfying that bb is a consecutive subsequence of aa.

Note that a consecutive subsequence of a sequence can be obtained by removing some (possibly zero) elements from the beginning and end of the sequence.

입력

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1051\le t\le 10^5), denoting the number of test cases.

For each test case, the first line contains one integer nn (3≤n≤3⋅1053\le n\le 3\cdot10^5), denoting the length of the integer sequence aa.

The second line contains nn integers a_1,a_2,⋯ ,a_na\_1,a\_2,\cdots,a\_n (1≤a_i≤1091\le a\_i\le10^9), denoting the sequence aa.

It is guaranteed that aa is a V-diagram, and the sum of nn over all test cases does not exceed 3⋅1053\cdot 10^5.

출력

For each test case, output a real number denoting the maximum of the average.

Your answer is considered correct if its absolute or relative error does not exceed 10−910^{-9}.

Formally, let your answer be xx, and the jury's answer be yy. Your answer is accepted if and only if ∣x−y∣max⁡(1,∣y∣)≤10−9\frac{|x-y|}{\max(1,|y|)}\le 10^{-9}.

예제1

  1. 예제 1

    입력
    2
    4
    8 2 7 10
    6
    9 6 5 3 4 8
    
    예상 출력
    6.75000000000000000000
    5.83333333333333303727