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

建议使用的浏览器:

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

3872:Dragon Ball

题目描述
There are N "dragon balls" lined up into one row from left to right. Every dragon ball has two properties: the type and energy. We can cut these balls into some segments ( these segments should not be empty). You can not change the order of these balls. In each segment, if there exists a ball which is not the right most one and its type is the same with the right most one ,this segment will explode. The energy of a segment is the energy of the ball with largest energy in this segment. Now please minimize the total energy of all these segments without explosion.
输入解释
There will be T (T<=10) test cases. Each test case contains three lines. The first line comes an Integer N (1<=N<=100000), the number of dragon balls. The second line contains N integer numbers, indicating the type of the dragon balls. The types will be a number between 1 and 100000. The last line of each case also contains N integer numbers, representing the energy of each ball. The energy will be positive and not greater than 1000000.
输出解释
For each case, print a line contains a number representing the minimum energy value.
输入样例
2
6
5 1 3 1 2 1
6 5 1 3 4 2
3
1 1 1
2 2 2
输出样例
8
6
来自杭电HDUOJ的附加信息
Recommend lcy

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

源链接: HDU-3872

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

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 65768/32768K(Java/Others)