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

建议使用的浏览器:

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

2272:Minimize The Difference

题目描述
Recently, Kiki are asked to arrange a competition. Before the competition, everyone have an expectation of the ranking. To make all the players happy , Kiki wants to minimize the sum of all the players’ difference. We define the difference of a player as |ai-bi|, ai stands for one’s expected ranking ,and bi stands for one’s final ranking.
输入解释
There are several test cases.
Each case begins with an integer n ,(n<= 100)stands for the number of players in this competition.
Then follows n lines ,each line contains a string s and an integer m,(the string will contains no more than 20 characters and no space in it, 1<=m<=n) stands for the name of the player and his expected ranking.
输出解释
The output contains one line for each data set : the minimum sum of differences Kiki can get.
输入样例
7
a 1
b 2
c 2
d 1
e 5
g 7
f 7
输出样例
5
提示
Hint 
One possible solution
1. a2. d3. b4. c5. e6. g7. f
来自杭电HDUOJ的附加信息
Author dandelion
Recommend lcy

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

源链接: HDU-2272

最后修改于 2020-10-25T22:52:02+00:00 由爬虫自动更新

共提交 0

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