fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // The GOAT ^_^
  5. int main() {
  6. int n, m;
  7. cin >> n >> m;
  8. int arr[n];
  9. int freq[100001] = {};
  10.  
  11.  
  12. // this time we will use frequency array :)
  13. for (int i = 0; i < n; i++) {
  14. cin >> arr[i];
  15. freq[arr[i]]++;
  16. }
  17.  
  18. for (int i = 1; i <= m; i++) {
  19. cout << freq[i] << endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 5320KB
stdin
10 5
1 2 3 4 5 3 2 1 5 3
stdout
2
2
3
1
2