hdoj 1236 排名

#include<stdio.h>
#include<string.h>
struct tt{
 char str[25];
 long  m;
 long total;
 long b[10];
};
int main()
{
 long N,M,G;
 long score[15];
 int i,j,l;
 struct tt stu[1000],temp;
 while(scanf("%ld",&N)!=EOF)
 {
  if(N==0) break;
  scanf("%ld%ld",&M,&G);
  for(i=0;i<1000;i++)
  stu[i].total=0;
  l=0;
  for(i=1;i<=M;i++)
   scanf("%ld",&score[i]);
  for(i=0;i<N;i++)
  {
   scanf("%s%ld",&stu[i].str,&stu[i].m);
   for(j=0;j<stu[i].m;j++)
   {
    scanf("%ld",&stu[i].b[j]);
    stu[i].total+=score[stu[i].b[j]];
   }
  }
  for(i=0;i<N;i++)
  {
   for(j=i;j<N;j++)
   {
    if(stu[i].total<stu[j].total)
    {
     temp=stu[i];
     stu[i]=stu[j];
     stu[j]=temp;
    }
    if(stu[i].total==stu[j].total)
    {
     if(strcmp(stu[i].str,stu[j].str))
     {
      temp=stu[i];
      stu[i]=stu[j];
      stu[j]=temp;
     }
    }
   }
  }//二级排序
  for(i=0;i<N;i++)
  {
   if(stu[i].total>=G)
    l++;
  }
  printf("%ld\n",l);
  for(i=0;i<l;i++)
  {
   printf("%s %ld\n",stu[i].str,stu[i].total);
  }
 }
 return 0;
}

/*
4 5 25
10 10 12 13 15
CS004 3 5 1 3
CS003 3 2 3 5
CS002 3 5 3 1
CS001 3 2 3 5
*/

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值