Problem: sort vector of pairs by second in reducing order, if the second's are the same, than sort by first in ascending order; inp, out: 3
20 80
30 90
25 90 ->
25 90
30 90
20 80
My code: ```#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<pair<int, int>> v;
int a, n, b, j;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a >> b;
v.push_back(pair<int, int>(a, b));
}
sort(begin(v), end(v), [](pair<int, int> a, pair<int, int> b)
{ return a.second > b.second; });
for (int i = 0; i < n; i++)
{
if (v[i].second == v[i + 1].second)
{
j = i + 1;
while (v[i].second == v[j].second)
j++;
sort(next(begin(v), i), next(begin(v), j), [](pair<int, int> a, pair<int, int> b){ return a.first < b.first; });
i = j;
}
}
for (auto a : v)
cout << a.first << ' ' << a.second << '\n';
return 0;
}```
how can i make this code faster?