送分题
写的比较精简 可以看看 不会请留言
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<pair<string, double>> stu;
int N, M, K;
cin >> N >> M >> K;
int sum = 0;
for (int i = 0; i < N; i++)
{
string s;
double a;
cin >> s >> a;
stu.push_back({s, a});
if (a >= M && a <= 100)
sum += 50;
else if (a >= 60 && a < M)
sum += 20;
}
sort(stu.begin(), stu.end(), [](auto e1, auto e2) { if(e1.second == e2.second)return e1.first < e2.first ;return e1.second > e2.second; });
int cnt;
cout << sum << endl;
//用来做标记
int t[104] = {0};
for (int i = 0;i<stu.size(); i++)
{
//如果这个成绩曾经没出现过 就更新
if (t[(int)stu[i].second] == 0)
cnt = i;
t[(int)stu[i].second] = 1;
if (cnt > K)
break;
cout << cnt + 1 << ' ' << stu[i].first << ' ' << stu[i].second << endl;
}
return 0;
}