fork download
  1. /*
  2.   Cred : SunnyYeahBoi
  3.   It's my last chance (⌐■_■)
  4.   Problem :
  5. */
  6.  
  7. #include<bits/stdc++.h>
  8.  
  9. using namespace std;
  10.  
  11. #define int long long
  12. #define double long double
  13. #define endl "\n"
  14. #define NAME "a"
  15.  
  16. const int MAXN = 1e6 + 5;
  17. const int inf = 1e18;
  18. const int MOD = 1e9 + 7;
  19.  
  20. void FileInput(){
  21. if(fopen(NAME".inp" , "r") == NULL)
  22. freopen(NAME".inp" , "w" , stdout);
  23. freopen(NAME".inp" , "r" , stdin);
  24. freopen(NAME".out" , "w" , stdout);
  25. }
  26.  
  27. int n , q;
  28. int a[MAXN];
  29. int cnt[MAXN];
  30. void solve(){
  31. cin >> n;
  32. for(int i = 1 ; i <= n ; i++)
  33. cin >> a[i];
  34.  
  35. for(int i = 1 ; i <= n ; i++)
  36. cnt[a[i]]++;
  37.  
  38. cin >> q;
  39. for(int i = 1 ; i <= q ; i++){
  40. int x;
  41. cin >> x;
  42. cout << cnt[x] << endl;
  43. }
  44. }
  45.  
  46. int32_t main(){
  47. FileInput();
  48. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  49. int t = 1;
  50. // cin >> t;
  51. while(t--)
  52. solve();
  53. return 0;
  54. }
  55.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty