https://www.acmicpc.net/problem/10816
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import sys
from collections import Counter
n=int(sys.stdin.readline())
cards=list(map(int, sys.stdin.readline().split()))
m=int(sys.stdin.readline())
to_find=list(map(int, sys.stdin.readline().split()))
counter_cards = Counter(cards)
for i in to_find:
#if i!=to_find[-1]:
print(counter_cards[i], end=' ')
# else:
# print(counter_cards[i], end='')
#print(counter_cards)
|
cs |
이분탐색 bisect를 써도 되긴하는데 Counter 쓰는게 좀 더 편한것같더라구용
출력에만 조심하셔요
Using bisect or Counter doesn't matter, but It is easier for me to use Counter
But Watch out your print
반응형
'python-algorithm' 카테고리의 다른 글
백준 18398 HOMWRK (0) | 2022.11.09 |
---|---|
백준 1966 프린터 큐 (0) | 2022.11.08 |
백준 11866 요세푸스 문제 0 (0) | 2022.11.08 |
Hacker rank Super Reduced String (0) | 2022.11.08 |
백준 18511 큰 수 구성하기 (0) | 2022.11.08 |
댓글