#include
#include
using namespace std;
bool compare(pair<string,int>a,pair<string,int>b)
{
if(a.second!=b.second)
return a.second>b.second;
else
return a<b;
}
void show_data(pair<string,int>a[],int n,int min_salary)
{
for(int i=0;i<n;i++)
{
if(a[i].second>=min_salary)
cout<<a[i].first<<" "<<a[i].second<<endl;
}
}
int main()
{
int min_salary;
cin>>min_salary;
int n;
cin>>n;
pair<string,int>p[n];
string s;
int m;
for(int i=0;i<n;i++)
{
cin>>s>>m;
p[i]=make_pair(s,m);
}
sort(p,p+n,compare);
show_data(p,n,min_salary);
return 0;
}
Problem with the code?
Code is fine just use bits/stdc++.h library to avoid headerfile related hassle
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.