结构体排序➕二分 | 1012 The Best Rank (25 point(s)

写法挺蠢,但是一次AC了也就算了吧2333333
1012 The Best Rank

#include 
#include 
const int N=2010;
const char nn[6]="*ACME";
struct Grade{
    int name;
    int sc[4];
}grade[N];
int n,m,gi,tot[N][5];
int cmp(const void* a, const void* b){
    return (*(Grade*)b).sc[gi]-(*(Grade*)a).sc[gi];
}
struct Rank{
    int name;
    int rr;
};
int r_cmp(const void* a, const void* b){
    return (*(Rank*)a).name-(*(Rank*)b).name;
}
Rank c_rank[N],m_rank[N],e_rank[N],a_rank[N];
void rec_rank(Rank rank[]){
    rank[0].name=grade[0].name;
    rank[0].rr=1;
    for (int i = 1; i < n; ++i) {
        rank[i].name=grade[i].name;
        if(grade[i].sc[gi]==grade[i-1].sc[gi])
            rank[i].rr=rank[i-1].rr;
        else rank[i].rr=i+1;
    }
    qsort(rank,n, sizeof(Rank),r_cmp);
}

int binary_search(int no){
    int l=0,r=n-1,m;
    while (l<=r){
        m=(l+r)/2;
        if(tot[m][0]>no)
            r=m-1;
        else if(tot[m][0]

你可能感兴趣的:(结构体排序➕二分 | 1012 The Best Rank (25 point(s))