//突破:用sort排序
#include<bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=a;i<b;i++)
const int N=1010;
int b[N]={0};
typedef struct Piont{
int x;
int y;
}P;
int cmp(P a,P b)
{
if(a.y!=b.y) return a.y>b.y;
else return a.x<b.x;
}
int main()
{
int n;
cin>>n;
int x;
_for(i,1,n+1)
{
cin>>x;
b[x]++;
}
vector<P> p(n);
int j=0;
_for(i,0,N)
{
if(b[i]!=0)
{
p[j].x=i;
p[j].y=b[i];
j++;
}
}
sort(p.begin(),p.end(),cmp);
_for(i,0,n)
{
if(p[i].y)
cout<<p[i].x<<" "<<p[i].y;
if(p[i+1].y>0 && i+1<n)
{
cout<<endl;
}
}
return 0;
}
|