1015 德才论 (25 分)

#include
#include

typedef struct StudentInf
{
    int ID;
    int de, cai, sum;
    int lv;

}Student;

int cmp( const void *a , const void *b )
{
  Student aa = *(Student*)a;
  Student bb = *(Student*)b;
  if(aa.lv != bb.lv)
    return aa.lv < bb.lv;
  else if(aa.de+aa.cai != bb.de+bb.cai)
    return (bb.de+bb.cai) > (aa.de+aa.cai);
  else if(aa.de != bb.de)
    return bb.de > aa.de;
  else
    return aa.ID > bb.ID;
}



int main()
{
    Student stu[100001];
    int N, L, H;
    scanf("%d %d %d", &N, &L, &H);

    int i, m=N;
    for(i=0; i= H&&stu[i].cai>=H) stu[i].lv = 1;
        else if(stu[i].de >= H && stu[i].cai= stu[i].cai) stu[i].lv = 3;
        else stu[i].lv = 4;
    }

    qsort(stu, N, sizeof(stu[0]), cmp);

    printf("%d\n", m);

    for(i=0; i

你可能感兴趣的:(1015 德才论 (25 分))