map是按从小到大的顺序自动排序的
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
map<int, int> cnt;
while (n -- )
{
int x;
scanf("%d", &x);
cnt[x] ++ ;
}
for (int i = 0; i < 2; i ++ )
cnt.erase(cnt.rbegin()->first);
auto bronze = cnt.rbegin();
cout << bronze->first << ' ' << bronze->second << endl;
return 0;
}