fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void executeTime() {
  5. cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " secs";
  6. }
  7.  
  8. int main() {
  9.  
  10.  
  11. int n, q; cin >> n >> q;
  12.  
  13. int arr[501];
  14.  
  15. for (int i = 0; i < n; i++) {
  16. cin >> arr[i];
  17. }
  18.  
  19. int query[501];
  20.  
  21. for (int i = 0; i < q; i ++) {
  22. cin >> query[i];
  23. }
  24.  
  25.  
  26. for (int i = 0; i < q; i++) {
  27. int key = query[i];
  28.  
  29. int cnt = 0;
  30. for (int j = 0; j < n; j++) {
  31. if (arr[j] == key) {
  32. cnt++;
  33. }
  34. }
  35.  
  36. cout << cnt << ' ';
  37. }
  38.  
  39. cout << endl;
  40.  
  41.  
  42. executeTime();
  43. return 0;
  44. }
Success #stdin #stdout #stderr 0s 5320KB
stdin
10 5
1 23 1 7 80
1 32 23 1 80

1 23 32 80 23
stdout
4 2 1 2 2 
stderr
Time Taken: 0.004367 secs