dh-winternagi 님의 블로그
(10816) 숫자 카드 2 본문
https://www.acmicpc.net/problem/10816
단계별로 풀어보기
14단계(집합과 맵) 5번째
숫자 카드와 다른 점이 카드 중복 가능 여부밖에 없어서 당연히 set만 multiset으로 바꿔서 푸는 게 정해인 줄 알았는데 시간 초과가 났다.
이분 탐색이나 map이 정해였나보다.

#include <iostream>
#include <map>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
map<int, int> mp;
cin >> n;
while(n--){
int t;
cin >> t;
mp[t]++;
}
cin >> m;
while(m--){
int t;
cin >> t;
cout << mp[t] << " ";
}
return 0;
}'백준 (C++) > Solve' 카테고리의 다른 글
| (1269) 대칭 차집합 (0) | 2026.04.14 |
|---|---|
| (1764) 듣보잡 (0) | 2026.04.14 |
| (1620) 나는야 포켓몬 마스터 이다솜 (0) | 2026.04.14 |
| (7785) 회사에 있는 사람 (0) | 2026.04.14 |
| (14425) 문자열 집합 (0) | 2026.04.14 |
