Từ 2025 HEMS 6
Thông tin
include <bits/stdc++.h>
using namespace std; vector<pair<string,int>> a; bool ss(pair<string,int> x,pair<string,int> y) { return (x.second > y.second) or (x.second == y.second && x.first < y.first); } int main() { int n; cin >> n; string name; int score; for (int i = 0;i<n;i++) { cin >> name >> score; a.push_back({name,score}); } sort(a.begin(),a.end(),ss); for (int i = 0;i<n;i++) { cout << a[i].first << " " << a[i].second << '\n'; } }