fork download
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int n;
  8. cin >> n;
  9.  
  10. int arr[n];
  11. for (int i = 0; i < n; i++) {
  12. cin >> arr[i];
  13. }
  14. int q;
  15. cin >> q;
  16. vector<int>hash(51,0);
  17.  
  18. for(int j =0;j<n;j++){
  19. hash[arr[j]]++;
  20. }
  21.  
  22. for (int i = 0; i < q; i++) {
  23. int query; cin>>query;
  24. cout<<hash[query]<<endl;
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5316KB
stdin
10 3
1 3 3 4 5 1 2 4 4 5
1
3
5
stdout
2
3
1
1
1