Ankit_132

C

Jul 1st, 2023
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ll     long long
  5. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  6. #define ff     first
  7. #define ss     second
  8. #define pb     push_back
  9.  
  10. int main()
  11. {
  12.     int n;
  13.     cin>>n;
  14.  
  15.     vector<pair<int, int>> vp(n);
  16.     for(auto &[a, b]: vp)       cin>>a>>b;
  17.  
  18.     vector<array<ll int, 3>> va;
  19.  
  20.     for(int i=0; i<n; i++)
  21.         va.pb({vp[i].ff, vp[i].ss, i+1});
  22.  
  23.     auto comp = [](array<ll int,3> a, array<ll int,3> b)
  24.     {
  25.         ll int v1 = a[0]*1ll*(b[0]+b[1]);
  26.         ll int v2 = b[0]*1ll*(a[0]+a[1]);
  27.  
  28.         if(v1 != v2)
  29.             return v1 > v2;
  30.         else
  31.             return a[2] < b[2];
  32.     };
  33.  
  34.     sort(va.begin(), va.end(), comp);
  35.  
  36.     for(auto [a, b, c]: va)
  37.         cout<<c<<" ";
  38.     cout<<"\n";
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment