Code getting error

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n];
map<int,int,greater> mp;
for(int i=0;i<n;i++)
{
cin>> a[i];
mp[a[i]]++;
}
multimap<int,int,greater > mpp;
for(auto it=mp.begin();it!=mp.end();it++)
{
mpp.insert(make_pair(it->second,it->first));
}
for(auto it=mpp.begin();it!=mpp.end();it++)
{
cout<second<<endl;
break;
}
}

but it works on some other compiler

@sunneykumar309,
But your code is working fine on sample test case on CB IDE.

@abhijeet.srivastava6499 i am getting TLE for 2 of the test cases .
I used hasing but still i getting TLE.
Is there any more efficient solution does exist?
Please reply fast

@sunneykumar309,
Code Here.
Problems asks for O(n) complexity, so you should use unordered_map.

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.