Recent Posts
Notice
No Rules Rules
숫자 카드 2 (feat. 백준, 10816번) 본문
728x90
반응형
숫자 카드 2
https://www.acmicpc.net/problem/10816
반응형
// woohyeon.kim
// https://www.acmicpc.net/problem/10816
#include <iostream>
#include <map>
using namespace std;
int main() {
ios::sync_with_stdio(false), cin.tie(NULL);
register int N, M;
map<int, int> ans;
cin >> N;
for (register int i = 0, v; i < N; ++i)
cin >> v, ++ans[v];
cin >> M;
for (register int i = 0, v; i < M; ++i) {
cin >> v;
if (ans.find(v) != ans.end())
cout << ans[v];
else
cout << 0;
cout << " ";
}
return 0;
}
// *&)*@*
자료구조 map을 이용하여 입력받은 정수형을 key로 갖고 그 횟수를 올려줍니다.
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
대칭 차집합 (feat. 백준, 1269번) (0) | 2022.08.03 |
---|---|
듣보잡 (feat. 백준, 1764번) (0) | 2022.08.03 |
나는야 포켓몬 마스터 이다솜 (feat. 백준, 1620번) (0) | 2022.08.03 |
문자열 집합 (feat. 백준, 14425번) (0) | 2022.08.03 |
숫자 카드 (feat. 백준, 10815번) (0) | 2022.08.03 |
Comments