senb1

krsu 785

Mar 8th, 2023
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.92 KB | None | 0 0
  1. /*
  2. * by: senb1
  3. */
  4. #include <algorithm>
  5. #include <iomanip>
  6. #include <iostream>
  7. #include <locale>
  8. #include <numeric>
  9. #include <cstring>
  10. #include <cmath>
  11.  
  12. #include <deque>
  13. #include <list>
  14. #include <map>
  15. #include <stack>
  16. #include <string>
  17. #include <vector>
  18. #include <array>
  19. #include <queue>
  20. #include <set>
  21.  
  22. using namespace std;
  23.  
  24. #define all(x) x.begin(), x.end()
  25. #define rall(x) x.rbegin(), x.rend()
  26. #define yes cout << "YES\n"
  27. #define no cout << "NO\n"
  28. #define fr first
  29. #define sc second
  30. #define endl "\n"
  31. #define ll long long
  32. #define ull unsigned long long
  33. #define ld long double
  34. #define nl cout << "\n";
  35.  
  36. const ll maxn = 1e6 + 10;
  37. const ll mod = 3e4;
  38. const int inf = 1000000000;
  39. const ull absmax = 1e18;
  40. // 4294967296
  41.  
  42. ll binpow(ll a, ll b) {
  43.     ll res = 1;
  44.     while (b > 0) {
  45.         if (b & 1)
  46.             res = res * a % mod;
  47.         a = a * a % mod;
  48.         b >>= 1 % mod;
  49.     }
  50.     return res % mod;
  51. }
  52.  
  53. ll divup(ll x, ll y) {
  54.     return (x - 1) / y + 1;
  55. }
  56.  
  57. ll gcd(ll a, ll b) {
  58.     if (a % b == 0)
  59.         return b;
  60.     if (b % a == 0)
  61.         return a;
  62.     if (a > b)
  63.         return gcd(a % b, b);
  64.     return gcd(a, b % a);
  65. }
  66.  
  67. ll lcm(ll a, ll b) {
  68.     return (a * b) / gcd(a, b);
  69. }
  70.  
  71. bool isPrime(int x) {
  72.     if (x <= 1) return false;
  73.     for (int i = 2; i <= sqrt(x); i++) {
  74.         if (x % i == 0)
  75.             return false;
  76.     }
  77.     return true;
  78. }
  79.  
  80. bool sortByScore(const pair<int, int>& a, const pair<int, int>& b) {
  81.     if (a.sc == b.sc)
  82.         return a.fr < b.fr;
  83.     return a.sc > b.sc;
  84. }
  85.  
  86. int main() {
  87.     ios::sync_with_stdio(0); cin.tie(0);
  88.     //cout << fixed << setprecision(12);
  89.     //setlocale(LC_ALL, "RUS");
  90.  
  91.     int n;
  92.     cin >> n;
  93.     vector<pair<int, int> > v(n);
  94.     for (int i = 0; i < n; i++)
  95.         cin >> v[i].fr >> v[i].sc;
  96.    
  97.     sort(all(v), sortByScore);
  98.     for (auto x : v)
  99.         cout << x.fr << ' ' << x.sc << endl;
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment