P1097 [NOIP2007 提高组] 统计数字

 

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long
#define ddd printf("-----------------debug\n");
using namespace std;

map<int,int> a;
set<int> b;
int n;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        a[x]++;//map key k--
        b.insert(x);
    }
    for(set<int>::iterator it=b.begin();it!=b.end();it++)
    {
        cout<<*it<<" "<<a[*it]<<endl;
    }
    return 0;
}
View Code

 

posted @ 2023-07-15 19:01  JMXZ  阅读(9)  评论(0)    收藏  举报