daily pastebin goal
85%
SHARE
TWEET

Untitled

a guest Nov 24th, 2017 54 in 11 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     freopen("input.txt", "r", stdin);
  9.     freopen("output.txt", "w", stdout);
  10.     int arrsz, num, tmp;
  11.     cin >> arrsz;
  12.     vector<int> arr(arrsz);
  13.     for (int i = 0; i < arrsz; ++i) {
  14.         cin >> arr[i];
  15.     }
  16.     sort(arr.begin(), arr.end());
  17.     cin >> num;
  18.     for (int i = 0; i < num; ++i) {
  19.         cin >> tmp;
  20.         cout << upper_bound(arr.begin(), arr.end(), tmp) -
  21.             lower_bound(arr.begin(), arr.end(), tmp) << " ";
  22.     }
  23.     cout << endl;
  24.     return 0;
  25. }
RAW Paste Data
Top