my code is giving
TESTCASE # 1 : run-error (Time: 0 s)
TESTCASE # 2 : wrong-answer (Time: 1.6 s)
TESTCASE # 3 : correct (Time: 0.34 s)
TESTCASE # 4 : timelimit (Time: 5.97 s)
please help me fix debugs in it???/
my code is giving
TESTCASE # 1 : run-error (Time: 0 s)
TESTCASE # 2 : wrong-answer (Time: 1.6 s)
TESTCASE # 3 : correct (Time: 0.34 s)
TESTCASE # 4 : timelimit (Time: 5.97 s)
please help me fix debugs in it???/
hi shubham
your code is not working for big testcases.
You just need to prepare a custom comparator to sort the employees.
Use an array of structures to store name of type string and salary of type int.
if you need any help regarding the code you can ping further.
i didn’t get u completely. mam,could you please show me the code for the same??
Mam, please reply!
i didn’t get how to go for the code according to idea you are suggesting
yes will help you with the logic. dont worry
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.