Sort game- one test case failing

code:
include bits/stdc++.h
using namespace std;

bool comparator(pair<string,int>p1,pair<string,int>p2)
{
if(p1.second==p2.second)
p1.first<p2.first;
return p1.second>p2.second;
}

int main() {
int x,n,i,sal;
string name;
cin>>x;
cin>>n;
pair<string,int>emp[n];
for(i=0;i<n;i++)
{
cin>>name>>sal;
emp[i].first=name;
emp[i].second=sal;
}
sort(emp,emp+n,comparator);

for(i=0;i<n;i++)
{
	if(emp[i].second>=x)
	cout<<emp[i].first<<" "<<emp[i].second<<endl;
}
return 0;

}

Hello @vashishthkuntal.gajjar2019 this is the corrected code nd it is passing every test case now.
#include<bits/stdc++.h>

using namespace std;

bool comparator(pair<string,int>p1,pair<string,int>p2)

{

if(p1.second==p2.second)

return p1.first<p2.first;

else

return p1.second>p2.second;

}

int main() {

int x,n,i,sal;

string name;

cin>>x;

cin>>n;

pair<string,int>emp[n];

for(i=0;i<n;i++)

{

cin>>name>>sal;

emp[i].first=name;

emp[i].second=sal;

}

sort(emp,emp+n,comparator);

for(i=0;i<n;i++)

{

if(emp[i].second>=x)

cout<<emp[i].first<<" "<<emp[i].second<<endl;

}

return 0;

}
if you have any doubt you can ask here:
Happy Learning!!

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.