CF1768F Wonderful Jump

题目描述

给定整数 $n$ 和长度为 $n$ 的序列 $a$。 从位置 $i$ 跳到位置 $j(1\leq i\leq j\leq n)$ 需要花费 $\min(a_i,a_{i+1},\cdots,a_j)\times(j-i)^2$ 枚金币。 对于 $k=1,2,\cdots,n$,求出从位置 $1$ 经若干次跳跃后跳到位置 $k$ 需要的最小金币总数。

输入格式

输出格式

说明/提示

In the first example: - From $ 1 $ to $ 1 $ : the cost is $ 0 $ , - From $ 1 $ to $ 2 $ : $ 1 \rightarrow 2 $ — the cost is $ \min(2, 1) \cdot (2 - 1) ^ 2=1 $ , - From $ 1 $ to $ 3 $ : $ 1 \rightarrow 2 \rightarrow 3 $ — the cost is $ \min(2, 1) \cdot (2 - 1) ^ 2 + \min(1, 3) \cdot (3 - 2) ^ 2 = 1 + 1 = 2 $ . In the fourth example from $ 1 $ to $ 4 $ : $ 1 \rightarrow 3 \rightarrow 4 $ — the cost is $ \min(1, 4, 4) \cdot (3 - 1) ^ 2 + \min(4, 4) \cdot (4 - 3) ^ 2 = 4 + 4 = 8 $ .