Advertisement
wery00

Untitled

Jan 29th, 2023
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n; cin >> n;
  8.     vector<pair<__int128_t, string>> pos(n);
  9.     for (int i = 0; i < n; i++) {
  10.         long long cc; cin >> cc;
  11.         __int128_t c = cc;
  12.         string b; cin >> b;
  13.         pos[i].second = to_string(cc) + " " + b;
  14.         for (char u : b) {
  15.             if (u == 'g') c *= 1;
  16.             if (u == 'p') c *= 16380;
  17.             if (u == 't') c *= 1000000;
  18.             if (u == 'm') c *= 1;
  19.             if (u == 'k') c *= 1000000;
  20.             if (u == 'M') c *= 1000000000;
  21.             if (u == 'G') c *= 1000000000000;
  22.         }
  23.         if(b.size() == 1) c *= 1000;
  24.         pos[i].first = c;
  25.     }
  26.     auto cmp = [](pair<__int128_t, string> p1, pair<__int128_t, string> p2) -> bool {
  27.         return p1.first < p2.first;
  28.     };
  29.     stable_sort(pos.begin(), pos.end(), cmp);
  30.     for (auto [c, s] : pos) {
  31.         cout << s << "\n";
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement