DHistory
[Baekjoon] Sort - 10816 숫자 카드 2 본문
문제
10816번: 숫자 카드 2
첫째 줄에 상근이가 가지고 있는 숫자 카드의 개수 N(1 ≤ N ≤ 500,000)이 주어진다. 둘째 줄에는 숫자 카드에 적혀있는 정수가 주어진다. 숫자 카드에 적혀있는 수는 -10,000,000보다 크거나 같고, 10,0
www.acmicpc.net
풀이
import sys
n = int(sys.stdin.readline().rstrip())
cards = list(map(int, sys.stdin.readline().rstrip().split()))
m = int(sys.stdin.readline().rstrip())
numbers = list(map(int, sys.stdin.readline().rstrip().split()))
def solution(cards, numbers):
counts = [0] * (10000000 * 2 + 2)
for number in cards:
counts[number] += 1
return [counts[number] for number in numbers]
print(*solution(cards, numbers))
채점 결과
'Computer Science > Algorithm' 카테고리의 다른 글
[Baekjoon] Sort - 10825 국영수 (0) | 2023.09.09 |
---|---|
[Baekjoon] Sort - 1764 듣보잡 (0) | 2023.09.09 |
[Baekjoon] Sort, Binary Search - 1920 수 찾기 (0) | 2023.09.09 |
[Baekjoon] Sort - 1251 단어 나누기 (0) | 2023.09.08 |
[Baekjoon] Sort - 5800 성적 통계 (0) | 2023.09.08 |