fork(1) 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 , q; cin>>n>>q;
  8. vector<int>arr(n);
  9. for(int i =0;i<n;i++){
  10. cin>>arr[i];
  11. }
  12. for(int i =0;i<q;i++){
  13. int query;
  14. cin>>query;
  15. int count =0;
  16. for(int i =0;i<n;i++){
  17. if(arr[i]==query){
  18. count++;
  19. }
  20. }
  21. cout<<"count of "<<query<<"is"<<count<<endl;
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5288KB
stdin
10 3
1 3 3 4 5 1 2 4 4 5
1
3
5
stdout
count of 1is2
count of 3is2
count of 5is2