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

建议使用的浏览器:

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

4384:King Kong II

题目描述
Have you seen the movie King Kong? If you have seen it, you must be impressed by the scene of the exciting fight between dinosaurs and King Kong, right? Though the dinosaurs have been fight off, King Kong has been injured very heavily. Considering that dinosaurs will come back very quickly, King Kong brings a lot of stones for fear that the dinosaurs attack again.
Now King Kong has arranged the stones at random in one line. But Different alignments of these stones would be different to King Kong. If the alignment is not the target in his mind, he will move the stones to their proper positions. Taking the physical consumption into consideration, King Kong could swap only two stones (whose weight is a and b weight units) at one time and for each time he will consume a+b thermal units. In order to minimize the physical consumption, King Kong should set a plan to move these stones. But this is too complex for king Kong and he needs your help.
输入解释
There are several test cases. For each test case, it contains:
Line 1: One integer N (1<=N<=50000) which specifies the total number of stones.
Line 2: N integers (you are ensured that the absolute value of each integer is less than 216) which the weight of each stone initially. These numbers specify the initial stone alignment. There is a blank between two consecutive integers.
Line 3: N integers (you are ensured that the absolute value of each integer is less than 216 ) which the weight of each stone finally. These numbers specify the target alignment in King Kong’s mind. There is a blank between two consecutive integers.
The input will be ended by zero.
输出解释
Output the Case number and the answer of the minimum total thermal units consumed by King Kong in the stone moving process.
输入样例
3
3 2 1
1 2 3
3
1 2 3
1 2 3
4
4 2 1 2
1 2 2 4
4
8 1 2 4
1 2 4 8
5
1 8 9 7 6
1 6 7 8 9
0
输出样例
Case 1: 4
Case 2: 0
Case 3: 8
Case 4: 17
Case 5: 41
来自杭电HDUOJ的附加信息
Author WHU
Recommend zhuyuanchen520

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

源链接: HDU-4384

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

共提交 0

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