Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- signed main()
- {
- int n , q , x;
- cin >> n >> q;
- vector<int> a(n);
- for(int i = 0; i < n; i++)
- cin >> a[i];
- sort(a.begin() , a.end()); // O(n logn)
- while(q--){
- cin >> x;
- auto e = equal_range(a.begin() , a.end() , x);
- cout << e.second - e.first << endl;
- /*
- int l = lower_bound(a.begin() , a.end() , x) - a.begin();
- int r = upper_bound(a.begin() , a.end() , x) - a.begin();
- cout << (r - l) << endl;*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement