301488: CF280E. Sequence Transformation

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Sequence Transformation

题意翻译

给你一个非减序列$x_1,x_2,...,x_n(1\le x_1\le x_2\le ... \le x_n \le q)$。你还有两个整数a和b$(a\le b, a(n-1)<q)$ 你要把序列变成$y_1,y_2,...,y_n(1\le y_i\le q, a\le y_{i+1}-y_i \le b)$ 变换的代价为$\sum_{i=1}^{n}{(x_i-y_i)^2}$ 最小化变换代价 Translated by Pine

题目描述

You've got a non-decreasing sequence $ x_{1},x_{2},...,x_{n} $ $ (1<=x_{1}<=x_{2}<=...<=x_{n}<=q) $ . You've also got two integers $ a $ and $ b $ $ (a<=b; a·(n-1)<q) $ . Your task is to transform sequence $ x_{1},x_{2},...,x_{n} $ into some sequence $ y_{1},y_{2},...,y_{n} $ $ (1<=y_{i}<=q; a<=y_{i+1}-y_{i}<=b) $ . The transformation price is the following sum: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF280E/179b07629f5c2880a487dce85a0ebc41e16d4717.png). Your task is to choose such sequence $ y $ that minimizes the described transformation price.

输入输出格式

输入格式


The first line contains four integers $ n,q,a,b $ $ (2<=n<=6000; 1<=q,a,b<=10^{9}; a·(n-1)<q; a<=b) $ . The second line contains a non-decreasing integer sequence $ x_{1},x_{2},...,x_{n} $ $ (1<=x_{1}<=x_{2}<=...<=x_{n}<=q) $ .

输出格式


In the first line print $ n $ real numbers — the sought sequence $ y_{1},y_{2},...,y_{n} $ $ (1<=y_{i}<=q; a<=y_{i+1}-y_{i}<=b) $ . In the second line print the minimum transformation price, that is, ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF280E/179b07629f5c2880a487dce85a0ebc41e16d4717.png). If there are multiple optimal answers you can print any of them. The answer will be considered correct if the absolute or relative error doesn't exceed $ 10^{-6} $ .

输入输出样例

输入样例 #1

3 6 2 2
1 4 6

输出样例 #1

1.666667 3.666667 5.666667 
0.666667

输入样例 #2

10 100000 8714 9344
3378 14705 17588 22672 32405 34309 37446 51327 81228 94982

输出样例 #2

1.000000 8715.000000 17429.000000 26143.000000 34857.000000 43571.000000 52285.000000 61629.000000 70973.000000 80317.000000 
797708674.000000

Input

题意翻译

给你一个非减序列$x_1,x_2,...,x_n(1\le x_1\le x_2\le ... \le x_n \le q)$。你还有两个整数a和b$(a\le b, a(n-1)<q)$ 你要把序列变成$y_1,y_2,...,y_n(1\le y_i\le q, a\le y_{i+1}-y_i \le b)$ 变换的代价为$\sum_{i=1}^{n}{(x_i-y_i)^2}$ 最小化变换代价 Translated by Pine

加入题单

算法标签: