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