Anime
시간 제한2초메모리 제한2048 MB
0과 n 사이를 벗어나지 않으면서 k초 앞뒤로 이동하는 버튼을 같은 횟수로 사용해 얻을 수 있는 최대 관심도 면적을 구한다.
문제
Aizhan is watching the last episode of the JJK. The duration of the last episode is exactly seconds. For every moment, she knows the level of interest: . Fortunately, function is a continuous piecewise linear function. She knows the values of at integer moments of time: . To get values at non-integer moments, she can draw the graph of the function with points for every integer from to , and then connect consecutive points by straight line segments. The interest of watching a fragment of the episode is the area under the graph for that fragment.
The video player is very strange. It has only two buttons: fast forward and rewind. The first button will forward the video by seconds, and the second button will rewind the video by seconds. So it is not possible to stop the video.
By trial and error, Aizhan noticed that it is not possible to forward the video or rewind it if she ends up outside of the episode's domain; in other words, she must stay in the time interval (domain expansion is not possible). The second peculiarity is the fact that the number of uses for both buttons should be equal after she has finished the episode; otherwise, her computer will blow up, which is not fun at all.
Aizhan has finished watching the episode without using the buttons, and the cumulative interest she got is the area under the graph of function . Now, she wonders what is the maximum possible cumulative interest if she uses the buttons optimally.
Note that the buttons can be used at any moment, even at non-integer moments. The buttons can be used any number of times, as long as, at the end of the episode, the first button is used the same number of times as the second one.
입력
On the first line, you are given two integers and (): the duration of the episode and the characteristic of the video player.
On the second line, you are given integers (): the level of interest at all the integer moments.
출력
In the single line, output one number: the answer for the problem.
Your answer is considered correct if its absolute or relative error does not exceed .
힌트
In the first example, Aizhan can use the forward button at moment , watch the time interval of the video, then rewind it to watch the time interval again.
Note that Aizhan watched time interval twice, and the area under this interval on the graph is . Thus, the cumulative interest is .