What is wrong with my solution?

#include
#include
#include
using namespace std;

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

int main()
{
long long int n,x;
cin>>x>>n;
pair<string,int> emp[10000];
string name;
int salary;
for(int i=0;i<n;i++)
{
cin>>name>>salary;
emp[i].first=name;
emp[i].second=salary;
sort(emp, emp+n, sorts);
}
for(int i=0;i<n;i++)
{
if(emp[i].second>=x)
{
cout<<emp[i].first<<" "<<emp[i].second<<endl;
}
}
return 0;
}

@tusharnitharwal The sort statement must be outside the for loop. You have taken it inside the loop. Try to correct that and then check. If still it does not work then please save your code on ide.codingblocks.com and then share its link.

It worked. Thanks a lot