gplt L2-027. 名人堂与代金券(水题 l2 最简单)

这次比赛l2最简单的题目 感觉比l1还简单

#include<bits/stdc++.h> //gplt L2-027. 名人堂与代金券(水题 l2 最简单)
using namespace std;    //就是排序  真的没别的了
const int maxn = 1e4 + 5;
struct node{
    int rank, score;
    string name;
}no[maxn];
int cmp(node a, node b){
    return a.score == b.score ? a.name < b.name : a.score > b.score;
}
int main(){
    int n, g, i, trank, rank, k, j, sum;
    cin >> n >> g >> k;
    getchar();
    for(i = 0, sum = 0; i < n ; i ++){//第一遍排序的时候可以直接算钱
        cin >> no[i].name >> no[i].score;
        if(no[i].score >= g)
            sum += 50;
        else if(no[i].score >= 60)
            sum += 20;
    }
    sort(no, no + n, cmp);//唯一需要想想的最多也就排名了 注意现在排名和当前人数的更新
    for(trank = 1, i = 0, rank = 1; i < n; i ++, rank ++){
        if(i && no[i].score != no[i - 1].score)
            trank = rank;
        no[i].rank = trank;
    }
    cout << sum << endl;
    for(i = 0; i < n; i ++){
        if(no[i].rank > k)
            break;
        cout << no[i].rank << " " << no[i].name << " " << no[i].score << endl;
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值