1075 PAT Judge

#include<iostream>
#include<algorithm>
using namespace std;

struct student{
    int id;
    int score[6]={0,-2,-2,-2,-2,-2};
    int num_of_perfect=0;
    int show=0;
    int rnk;
};
//-2表示没有提交过
//-1表示提交过,没有编译
//0以及以上,过了编译


int N,K,M;//N用户数,K题目数,M提交次数
int total[6];
student s[100000];

bool comp(student x,student y){
    if(x.score[0]!=y.score[0])return x.score[0]>y.score[0];
    if(x.num_of_perfect!=y.num_of_perfect)return x.num_of_perfect>y.num_of_perfect;
    if(x.show!=y.show)return x.show>y.show;
    return x.id<y.id;
}

int main()
{
    int i,j,k;
    cin>>N>>K>>M;
    for(i=1;i<=K;i++)cin>>total[i];
    while(M--){
        cin>>i>>j>>k;
        if(k>=0)s[i].show=1;
        if(k>s[i].score[j])s[i].score[j]=k;
    }
    for(i=1;i<=N;i++){
        s[i].id=i;
        for(j=1;j<=K;j++){
            if(s[i].score[j]>=0)s[i].score[0]+=s[i].score[j];
            if(s[i].score[j]==total[j])s[i].num_of_perfect++;
        }
    }
    
    sort(s+1,s+N+1,comp);
        for(i=1;i<=N;i++){
            if(i==1||s[i].score[0]!=s[i-1].score[0]){
                s[i].rnk=i;
            }
            else{
                s[i].rnk=s[i-1].rnk;
            }
        }
        
        for(i=1;i<=N;i++){
            if(s[i].show==0)break;
            printf("%d %05d %d",s[i].rnk,s[i].id,s[i].score[0]);
            for(j=1;j<=K;j++){
                if(s[i].score[j]==-2)cout<<" -";
                else if(s[i].score[j]==-1)cout<<" 0";
                else cout<<' '<<s[i].score[j];
            }
            cout<<endl;
        }
}

//  1   2   3   4   5   6   7   8   9
//  10  95  95  90  85  85  85  85  80
//  1   2   3   4   5   6   7   8   9
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

上官唐云

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值