fork download
  1. #include<bits/stdc++.h>
  2.  
  3. #pragma GCC optimize("O2")
  4. #pragma GCC optimize("O3")
  5. #pragma GCC optimize("Ofast")
  6.  
  7. #define pii pair<int,int>
  8. #define ii int,int
  9. #define fi first
  10. #define se second
  11. #define pb push_back
  12. #define lb lower_bound
  13. #define ub upper_bound
  14. #define umap unordered_map
  15. #define BIT(mask, i) ((mask >> i)&1)
  16. #define ALL(c) c.begin(), c.end()
  17.  
  18. using namespace std;
  19.  
  20. mt19937 rd(chrono::high_resolution_clock::now().time_since_epoch().count());
  21. int rand(int l, int r){
  22. return l + rd()*rd()%(r-l+1);
  23. }
  24.  
  25. const int N = 1e6+7;
  26. const int M = 1e3+3;
  27. const int MOD = 1e9+7;
  28. const int inf = 3e18;
  29.  
  30. int n;
  31.  
  32. signed main(){
  33. ios_base::sync_with_stdio(0);
  34. cin.tie(0);
  35. cout.tie(0);
  36. cin >> n;
  37. map<long long, int> mp;
  38.  
  39. for(int i = 1; i <= n; i++){
  40. long long x;
  41. cin >> x;
  42. mp[x]++;
  43. } // đếm được mỗi phần tử xuất hiện bao nhiêu lần rồi
  44. // -> in ra map -> thỏa mãn đề bài
  45. for(auto i : mp){
  46. cout << i.first << ' ' << i.second << '\n';
  47. }
  48. }
  49.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty