当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6284:Longest Increasing Subsequence

题目描述
Bobo has a sequence $a_1, a_2, \dots, a_n$.
Let $f(x)$ be the length of longest *strictly* increasing subsequence after replacing all the occurrence of $0$ with $x$.
He would like to find $\sum_{i = 1}^n i \cdot f(i)$.

Note that the length of longest strictly increasing subsequence of sequence $s_1, s_2, \dots, s_m$ is the largest $k$
such that there exists $1 \leq i_1 < i_2 < \dots < i_k \leq m$ satisfying $s_{i_1} < s_{i_2} < \dots < s_{i_k}$.
输入解释
The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains an integer $n$.
The second line contains $n$ integers $a_1, a_2, \dots, a_n$.
输出解释
For each test case, print an integer which denotes the result.

## Constraint

* $1 \leq n \leq 10^5$
* $0 \leq a_i \leq n$
* The sum of $n$ does not exceed $250,000$.
输入样例
2
1 1
3
1 0 3
6
4 0 6 1 0 3
输出样例
3
14
49
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6284

最后修改于 2020-10-25T23:29:58+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)