fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long;
  4.  
  5. struct nguoi{
  6. string ten;
  7. int tuoi;
  8. };
  9.  
  10. bool cmp(nguoi x, nguoi y)
  11. {
  12. if(x.tuoi != y.tuoi)
  13. {
  14. return x.tuoi > y.tuoi;
  15. }
  16. else
  17. {
  18. return x.ten < y.ten;
  19. }
  20. }
  21.  
  22. int main() {
  23. int n; cin >> n;
  24. nguoi a[n+1];
  25. for(int i = 0; i < n; i++)
  26. {
  27. cin.ignore();
  28. getline(cin, a[i].ten);
  29. cin >> a[i].tuoi;
  30. }
  31. sort(a,a+n,cmp);
  32. for(int i = 0; i < n; i++)
  33. {
  34. cout << a[i].ten << "\n";
  35. }
  36. /* Enter your code here. Read input from STDIN. Print output to STDOUT */
  37. return 0;
  38. }
Success #stdin #stdout 0.02s 5304KB
stdin
Standard input is empty
stdout