Sort game prob(Giving Run Error)

#include
#include
#include
using namespace std;
bool compare(pair<string,int>a,pair<string,int>b){
if(a.second==b.second){
return a.first<b.first; //lexicographical sorting if salary is same
}
else{
return a.second>b.second;
}
}
int main() {
int x;
cin>>x;
int N;
cin>>N;
pair<string,int>emp_arr[1000];
string s;
int sal;
for(int i=0;i<N;i++){
cin>>s>>sal;
emp_arr[i].first=s;
emp_arr[i].second=sal;
}
sort(emp_arr,emp_arr+N,compare);
for(int i=0;i<N;i++){
if(emp_arr[i].second>=x){
cout<<emp_arr[i].first<<" "<<emp_arr[i].second<<endl;
}
}
return 0;
}
IT is giving correct ans in compilation.

hello @Ramitcodingblocks,
value of n can be upto 10^5 so increase ur array size