题解 | 排名
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
struct stP {
string id;
int score;
stP(string id, int score): id(id), score(score) {}
bool operator<(stP b){
if(score==b.score)return id<b.id;
else return score>b.score;
}
};
int main() {
int n, m, g;
while (cin >> n) {
if (n == 0)break;
cin >> m >> g;
int score[m];
for (int i = 0; i < m; i++)cin >> score[i];
vector<stP>a;
while (n--) {
string id;
int k;
cin >> id >> k;
int ap = 0;
while (k--) {
int y;
cin >> y;
ap += score[y-1];
}
bool pass = false;
if (ap >= g)a.push_back(stP(id, ap));
}
sort(a.begin(), a.end());
cout<<a.size()<<endl;
for(auto x:a){
cout<<x.id<<" "<<x.score<<endl;
}
}
}
难度在于复杂的输入函数,其他的就非常简单的,唯一的要求就是输出及格的,我这里为了方便就只存了及格的,然后要求同分数按照序号排序,这个直接利用string比较方法即可



