10816 숫자카드2
https://www.acmicpc.net/problem/10816
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
vector<long long> vec;
int N,M;
long long temp;
cin >> N;
while (N--)
{
cin >> temp; vec.push_back(temp);
}
sort(vec.begin(), vec.end());
cin >> M;
while (M--)
{
cin >> temp;
cout << upper_bound(vec.begin(), vec.end(), temp) - lower_bound(vec.begin(), vec.end(), temp) << " ";
}
}
lowerbound와 upperbound를 이용하여 이분탐색으로 원하는 수를 찾고, 그 수의 개수를 찾을 수 있다.