길이가 3 이상인 모든 접두사에 대해, 원형으로 x_i + x_{i+1} <= a_i를 만족하는 음이 아닌 x_i들의 합의 최댓값을 구한다.
어려움9수학그리디동적 계획법구현아직 제출이 없습니다시간 제한1초메모리 제한512 MBGiven an array of non-negative integers s_1,…,s_n with n≥3, let's call a sequence of n non-negative numbers (not necessarily integers) x_1,x_2,…,x_n \textit{balanced} if for each i, the constraint x_i+x_i+1≤s_i is satisfied, where x_n+1=x_1.
Let's denote f(s_1,s_2,…,s_n) as the largest x_1+x_2+…+x_n among all balanced configurations of weights.
You are given an array of non-negative integers a_1,a_2,…,a_n.
Find n−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).
The first line contains one integer n (3≤n≤100,000).
The second line contains n integers a_1,a_2,…,a_n (0≤a_i≤100,000).
Print n−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).
Your answer will be considered correct if the relative or absolute error of all values in it is at most 10−9.
In the first example, for the prefix with three elements we can set values 10,10,10, for the next prefix we can set values 10.1,9.9,10.1,4.9.