ac

root  •  2年前


include

include

include

include

using namespace std; struct node{

int x;
int c = 1;

}a[1500000]; int n; int cmp(node p, node q) {

return p.x < q.x;

} int main() {

scanf("%d",&n);
for (int i = 1;i <= n;i++)scanf("%d",&a[i].x);
sort(a + 1,a + n + 1,cmp);
for (int i = 1;i <= n;i++)
{
    if(a[i].x == a[i+1].x)
    {
        a[i].x = 0;
        a[i+1].c += a[i].c;
    }
    if(a[i].x != 0)printf("%d %d\n",a[i].x,a[i].c);
} 
return 0;

}


评论:

请先登录,才能进行评论