#46201: set + map


1121228@stu.wghs.tp.edu.tw (你知道我是誰嗎!!??)

學校 : 臺北市私立薇閣高級中學
編號 : 266561
來源 : [60.248.154.139]
最後登入時間 :
2025-08-21 12:45:57

#include <bits/stdc++.h>
using namespace std;

int main() {
    map<int, int> m;
    set<int> s;
    int n, tmp;
    cin >> n;
    while(n--){
        cin >> tmp;
        s.insert(tmp);
        if(m.find(tmp)!=m.end()){
            m[tmp]++;
        }else{
            m.insert(pair<int, int>(tmp, 1));
        }
    }
    for(int x : s){
        cout << x << ' ' << m[x] << endl;
    }
    return 0;
}