Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define ff first
- #define ss second
- #define pb push_back
- int main()
- {
- int n;
- cin>>n;
- vector<pair<int, int>> vp(n);
- for(auto &[a, b]: vp) cin>>a>>b;
- vector<array<ll int, 3>> va;
- for(int i=0; i<n; i++)
- va.pb({vp[i].ff, vp[i].ss, i+1});
- auto comp = [](array<ll int,3> a, array<ll int,3> b)
- {
- ll int v1 = a[0]*1ll*(b[0]+b[1]);
- ll int v2 = b[0]*1ll*(a[0]+a[1]);
- if(v1 != v2)
- return v1 > v2;
- else
- return a[2] < b[2];
- };
- sort(va.begin(), va.end(), comp);
- for(auto [a, b, c]: va)
- cout<<c<<" ";
- cout<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment