Logo
(追記) (追記ここまで)

18571번 - Calculating Average 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB179442718.750%

문제

Bytelandian schools have a rather unusual average mark calculation system. Students’ marks are represented as an array a of n integers. At the end of a term, the teacher picks any mark with index k in array a. Then the student may choose any consecutive segment of marks that contains the k-th mark (that is, the one chosen by the teacher). The final mark is the average value of marks on this segment.

You study in a Bytelandian school and want to find out which mark you can obtain. Since you don’t know the index the teacher will choose, you need to calculate the highest possible average mark for each possible index k. Formally, for each k you need to find the maximum possible average value of a subsegment that contains the k-th element of the array a.

입력

The first line contains a single integer n (1 ≤ n ≤ 2 · 105), the amount of marks.

The second line contains n integers ai (0 ≤ ai ≤ 109) separated by spaces: the array of your marks.

출력

Print n lines. In the i-th line, print the maximum possible average mark if the teacher chose index i. The answer is considered correct if its absolute or relative error does not exceed 10−6.

제한

예제 입력 1

6
2 4 5 7 3 6

예제 출력 1

4.500000
5.333333
6.000000
7.000000
5.333333
6.000000

힌트

For k = 1, you can choose the entire array, and the answer will be (2+4+5+7+3+6)/6 = 4.5.

For k = 2, you can choose the second, the third and the fourth marks, and the answer will be (4+5+7)/3 = 5+1/3.

For k = 3, you can choose the third and the fourth marks, and the answer will be (5+7)/2 = 6.

For k = 4, you can choose the fourth mark and get the answer 7.

For k = 5, you can choose the last three marks and get the answer (7+3+6)/3 = 5+1/3.

For k = 6, you can choose the last mark and get the answer 6.

It can be shown that these answers are optimal.

출처

Camp > Petrozavodsk Programming Camp > Winter 2019 > Day 6: Belarusian SU Contest C번

Contest > Open Cup > 2018/2019 Season > Stage 12: Grand Prix of Belarus C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /