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. int q;
  10. cin >> q;
  11.  
  12. int arr[n];
  13. for (int i = 0; i < n; i++) {
  14. cin >> arr[i];
  15. }
  16.  
  17. vector<int>hash(51,0);
  18.  
  19. for(int j =0;j<n;j++){
  20. hash[arr[j]]++;
  21. }
  22.  
  23. for (int i = 0; i < q; i++) {
  24. int query; cin>>query;
  25. cout<<hash[query]<<endl;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 5324KB
stdin
10 3
1 3 3 4 5 1 2 4 4 5
1
3
5
stdout
2
2
2