fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. ios::sync_with_stdio(false);
  7. cin.tie(nullptr);
  8.  
  9. int n, m;
  10. cin >> n;
  11. int t[n];
  12. for (int i = 0; i < n; i++) cin >> t[i];
  13.  
  14. cin >> m;
  15. int x;
  16. for (int i = 0; i < m; i++) {
  17. cin >> x;
  18. auto range = equal_range(t, t + n, x);
  19. int count = range.second - range.first;
  20. cout << count << '\n';
  21. }
  22.  
  23. return 0;
  24. }
  25.  
  26.  
Success #stdin #stdout 0.01s 5284KB
stdin
7
1 1 1 2 4 7 7
3
1
3
7
stdout
3
0
2