Sort Game , I have used structure in the code first , but it is not working

@vanshu21 Your logic for the code is right but it does not work for big test cases and give TLE.
Please try sorting using STL sort function with comparator which internally uses randomized quick sort whose complexity is lesser and may pass all the test cases.
Code would be like this:
1)create a pair of employees where 1st element will be the name of employee and 2nd will be salary.
pair<string,int> emp[100005];
2) then input the string and salary.
for(int i=0;i<n;i++)
{
cin>>name>>salary;
emp[i].first=name;
emp[i].second=salary;
}
3) then write the custom compartor function.
bool mycompare(pair<string,int> p1,pair<string,int> p2)
{
if(p1.second==p2.second)
{
return p1.first<p2.first;
}
return p1.second>p2.second;
}
sort the pair
sort(emp,emp+n,mycompare);
then apply the required condition and return the result.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.