这次比赛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;
}