Advertisement
wery00

Untitled

Jan 29th, 2023
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 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.     stable_sort(pos.begin(), pos.end(), [](auto p1, auto p2) {return p1.first < p2.first;});
  27.     for (auto [c, s] : pos) {
  28.         cout << s << "\n";
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement