#55152: cpp_answer


yp11451202@yphs.tp.edu.tw (705-38黃鈺潤)


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,c;
    cin>>a;
    vector<int> b;
    queue<int> d;
    for(int i=0;i<a;i++)
    {
        cin>>c;
        b.push_back(c);
    }
    sort(b.begin(),b.end());
    for(int num : b)
    {
        d.push(num);
    }
    int y,z,ma=0,f;
    queue<int> p;
    while(!d.empty())
    {
        y=0;
        z=d.front();
        f=d.front();
        while(f==z)
        {
            d.pop();
            f=d.front();
            y++;

        }
        if(ma<y)
        {
            ma=y;
            while(!p.empty())
            {
                p.pop();
            }
            p.push(z);
        }
        else if(ma==y)
        {
            p.push(z);
        }
    }
    while(!p.empty())
    {
        cout<<p.front()<<" "<<ma<<endl;
        p.pop();
    }
    return 0;
}