#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
struct Student {
string name;
int score;
// 新增:带参构造
Student(const string& n, int s) : name(n), score(s) {}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
if (!(cin >> n)) return 0;
vector<Student> students;
students.reserve(n);
for (int i = 0; i < n; ++i) {
string name;
int score;
cin >> name >> score;
students.emplace_back(name, score); // 现在可以成功匹配构造函数
}
sort(students.begin(), students.end(),
[](const Student& a, const Student& b) { return a.score > b.score; });
for (const auto& s : students)
cout << s.name << ' ' << s.score << '\n';
return 0;
}
测试点2和6WA,有没有大佬能调一下 蒟蒻太久没登谷了连红题都做不起了:(