Circles

길이가 3 이상인 모든 접두사에 대해, 원형으로 x_i + x_{i+1} <= a_i를 만족하는 음이 아닌 x_i들의 합의 최댓값을 구한다.

어려움9수학그리디동적 계획법구현아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Given an array of non-negative integers s_1,,s_ns\_1, \ldots, s\_n with n3n \geq 3, let's call a sequence of nn non-negative numbers (not necessarily integers) x_1,x_2,,x_nx\_1, x\_2, \ldots, x\_n \textit{balanced} if for each ii, the constraint x_i+x_i+1s_ix\_i + x\_{i+1} \leq s\_i is satisfied, where x_n+1=x_1x\_{n+1}=x\_1.

Let's denote f(s_1,s_2,,s_n)f(s\_1, s\_2, \ldots, s\_n) as the largest x_1+x_2++x_nx\_1 + x\_2 + \ldots + x\_n among all balanced configurations of weights.

You are given an array of non-negative integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n

Find n2n-2 numbers: f(a_1,a_2,a_3),f(a_1,a_2,a_3,a_4),,f(a_1,a_2,a_3,,a_n)f(a\_1, a\_2, a\_3), f(a\_1, a\_2, a\_3, a\_4), \ldots, f(a\_1, a\_2, a\_3, \ldots, a\_n).

입력

The first line contains one integer nn (3n100,000)3 \leq n \leq 100\\,000).

The second line contains nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n (0a_i100,0000 \leq a\_i \leq 100\\,000).

출력

Print n2n-2 numbers: f(a_1,a_2,a_3),f(a_1,a_2,a_3,a_4),,f(a_1,a_2,a_3,,a_n)f(a\_1, a\_2, a\_3), f(a\_1, a\_2, a\_3, a\_4), \ldots, f(a\_1, a\_2, a\_3, \ldots, a\_n).

Your answer will be considered correct if the relative or absolute error of all values in it is at most 10910^{-9}.

힌트

In the first example, for the prefix with three elements we can set values 10,10,10\\{10, 10, 10\\}, for the next prefix we can set values 10.1,9.9,10.1,4.9\\{10.1, 9.9, 10.1, 4.9\\}.