结构体+sort方法

昨天做了一道简单但很麻烦的题,我只能想到结构体,并用了STL的sort方法解决了它.不过从中有许多细节问题.

题目:

 

Problem Description

  Lcy wanted to choose 50 ACMers from m players to join HDU-ACM team.
He made n competitions , and now is your task to make the ranklist.
Here’re some instructions :
Effective score : the sum of the best n-2 competitions’ score.
One’s score in one competition : number of problems he(or she) solved divided the sum of problems all players solved.

The ranklist is made , of course , by the effective score , what if some players have the same score ?Follow these rules : girls always come first , same again and younger first , again ? In lexicographic order.

Input

  For each case , two integers in the first line : n (3<= n <= 10)and m(m<=1000)
The next m lines are someone’s information :
name , sex (F,M), grade and n integer numbers which means one’s number of solved problem in the ith competition.

Output

Output the first fifty players in order . Output all if m<50.

Sample Input

3 2
WXL F 08 3 4 5
HH M 08 3 4 5

Sample Output

WXL
HH

 

代码如下:

 

Code
posted @ 2009-05-04 17:04  Orangefish  阅读(1309)  评论(0编辑  收藏  举报