Advertisement
wery00

Untitled

Jan 29th, 2023
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 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<int, string>> mas(n);
  9.     vector<pair<__int128_t, int>> pos(n);
  10.     for (int i = 0; i < n; i++) {
  11.         long long cc; cin >> cc;
  12.         __int128_t c = cc;
  13.         string b; cin >> b;
  14.         mas[i] = {c, b};
  15.         for (char u : b) {
  16.             if (u == 'g') c *= 1;
  17.             if (u == 'p') c *= 16380;
  18.             if (u == 't') c *= 1000000;
  19.             if (u == 'm') c *= 1;
  20.             if (u == 'k') c *= 1000000;
  21.             if (u == 'M') c *= 1000000000;
  22.             if (u == 'G') c *= 1000000000000;
  23.         }
  24.         if(b.size() == 1) c *= 1000;
  25.         pos[i] = {c, i};
  26.     }
  27.     sort(pos.begin(), pos.end());
  28.     for (auto [num, pos] : pos) {
  29.         cout << mas[pos].first << " " << mas[pos].second << "\n";
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement