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

建议使用的浏览器:

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

6611:K Subsequence

题目描述
Master QWsin is dating with Sindar. And now they are in a restaurant, the restaurant has $n$ dishes in order. For each dish, it has a delicious value $ai$. However, they can only order $k$ times. QWsin and Sindar have a special ordering method, because they believe that by this way they can get maximum happiness value.

Specifically, for each order, they will choose a $subsequence$ of dishes and in this $subsequence$, when $i < j$, the subsequence must satisfies $ai \leq aj$. After a round, they will get the sum of the $subsequence$ and they can't choose these dishes again.

Now, master QWsin wants to know the maximum happiness value they can get but he thinks it's too easy, so he gives the problem to you. Can you answer his question?
输入解释
There are multiple test cases. The first line of the input contains an integer $T$, indicating the number of test cases. For each test case:

First line contains two positive integers $n$ and $k$ which are separated by spaces.

Second line contains $n$ positive integer $a1$,$a2$,$a3$...$an$ represent the delicious value of each dish.


$1 \leq T \leq 5$

$1 \leq n \leq 2000$

$1 \leq k \leq 10$

$1 \leq ai \leq 1e5$
输出解释
Only an integer represent the maximum happiness value they can get.
输入样例
1

9 2
5 3 2 1 4 2 1 4 6
输出样例
22
来自杭电HDUOJ的附加信息
Recommend chendu

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

源链接: HDU-6611

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

共提交 0

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