您的位置:首页 > 其它

Tyvj 1130 奖学金

2011-08-19 12:56 99 查看
题目:

奖学金

来源:

Tyvj 1130

题目大意:

先根据输入的3门课的成绩计算总分,然后按上述规则排序,最后按排名顺序输出前5名学生的学号和总分,输出前5名学生的学号和总分

数据范围:

6<=n<=300

样例:

6
90 67 80
87 66 91
78 89 91
88 99 77
67 89 64
78 89 98
6 265

4 264

3 258

2 244

1 237

做题思路:

貌似要按三个顺序排序,多关键字快排解决哈

知识点:

排序

type
act=record
id,x,ch:longint;
end;
var
a:array[0..310]of act;
i,n,t:longint;
procedure qsort(l,r:longint);
var
i,j:longint;
k,t:act;
begin
i:=l;j:=r;
k:=a[(l+r) shr 1];
repeat
while(a[i].x>k.x)or((a[i].x=k.x)and(a[i].ch>k.ch))or((a[i].x=k.x)and(a[i].ch=k.ch)and(a[i].id>k.id))  do inc(i);
while(a[j].x<k.x)or((a[j].x=k.x)and(a[j].ch<k.ch))or((a[j].x=k.x)and(a[j].ch=k.ch)and(a[j].id>k.id))  do dec(j);
ifi<=j then
begin
t:=a[i];a[i]:=a[j];a[j]:=t;
inc(i);dec(j);
end;
until i>j;
ifi<r then qsort(i,r);
ifj>l then qsort(l,j);
end;
begin
readln(n);
fori:=1 to n do
begin
read(a[i].ch);
read(t);
inc(a[i].x,t);
inc(a[i].x,a[i].ch);
readln(t);
inc(a[i].x,t);
a[i].id:=i;
end;
qsort(1,n);
fori:=1 to 5 do
begin
writeln(a[i].id,' ',a[i].x);
end;
end.
题目来源:http://www.tyvj.cn:8080/Problem_Show.asp?id=1130
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: