# Solution - F. số lân xuất hiện > [name= Nhỏ hơn ba nghìn một trăm mười chín ] > > [color=#ff5188] - B1: Sort mảng (list) - B2: Dùng ***unordered_map*** (***Dict***) đếm số lần xuất hiện. - B3: in số lần xuất hiện **đpt:** $O(n.log(n))$ ### ***Code tham khảo*** Python ```python= n = int(input()) a = [int(i) for i in input().split()] dic = {} for i in a: dic[i] = 0 for i in a: dic[i] += 1 a = list(set(a)) a.sort() for i in a: print(i, dic[i]) ``` *C++* ```cpp= #include <bits/stdc++.h> #define int long long using namespace std; signed main(){ int n; cin >> n; vector<int> a(n); unordered_map<int, int> ma; for(int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end(), greater<int>()); for(int i = 0; i < n; i++) ma[a[i]] += 1; for(auto e: ma) cout << e.first << " " << e.second << "\n"; } ```