提交时间:2026-01-04 15:42:51
运行 ID: 81240
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Student { string name; int score; }; bool compare(const Student& a, const Student& b) { if (a.score != b.score) return a.score > b.score; return a.name < b.name; } int main() { int n; cin >> n; vector<Student> students(n); for (int i = 0; i < n; ++i) { cin >> students[i].name >> students[i].score; } sort(students.begin(), students.end(), compare); for (const auto& student : students) { cout << student.name << " " << student.score << endl; } return 0; }