编程介的小学生 2019-08-12 21:52 采纳率: 20.5%
浏览 147

C语言是怎么才能实现的,集体的代码

Problem Description
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.

Input
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.

Output
The output contains one line for each data set : the minimum sum of differences Kiki can get.

Sample Input
7
a 1
b 2
c 2
d 1
e 5
g 7
f 7

Sample Output
5
Hint

Hint
One possible solution
1. a2. d3. b4. c5. e6. g7. f

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧
    • ¥15 #MATLAB仿真#车辆换道路径规划