https://www.acmicpc.net/problem/10816
10816번: 숫자 카드 2
첫째 줄에 상근이가 가지고 있는 숫자 카드의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 숫자 카드에 적혀있는 정수가 주어진다. 숫자 카드에 적혀있는 수는 -10,000,000보다 크거나 같고, 10,
www.acmicpc.net
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
unordered_map<int, int> list;
int N, M;
int search;
cin >> N;
for (int i = 1; i <= N; i++) {
int num;
cin >> num;
if (list[num] > 0) list[num]++;
else list[num] = 1;
}
cin >> M;
for (int i = 1; i <= M; i++) {
cin >> search;
if (list[search] > 0) cout << list[search] << " ";
else cout << "0 ";
}
return 0;
}
'APS > 백준' 카테고리의 다른 글
[21924] 도시 건설 C++ (0) | 2022.03.05 |
---|---|
[14716] 현수막 C++ (0) | 2022.03.05 |
[3745] 오름세 C++ (0) | 2022.03.02 |
[17245] 서버실 C++ (0) | 2022.02.21 |
[2110] 공유기 설치 C++ (0) | 2022.02.13 |