λ°±μ€ 10816: μ«μ μΉ΄λ 2 (Python)
https://www.acmicpc.net/problem/10816
10816λ²: μ«μ μΉ΄λ 2
첫째 μ€μ μκ·Όμ΄κ° κ°μ§κ³ μλ μ«μ μΉ΄λμ κ°μ N(1 ≤ N ≤ 500,000)μ΄ μ£Όμ΄μ§λ€. λμ§Έ μ€μλ μ«μ μΉ΄λμ μ νμλ μ μκ° μ£Όμ΄μ§λ€. μ«μ μΉ΄λμ μ νμλ μλ -10,000,000λ³΄λ€ ν¬κ±°λ κ°κ³ , 10,
www.acmicpc.net
μ±μ νλλ°λ§ 1λΆ 30μ΄λ κ±Έλ €μ λ μ²μμ μκ° μ΄κ³Ό λ¨λ μ€^^,,
import sys
n = int(input())
card = sorted(map(int, sys.stdin.readline().split()))
m = int(input())
find = list(map(int, sys.stdin.readline().split()))
dict_card = dict()
for i in card:
if i in dict_card:
dict_card[i] += 1
else:
dict_card[i] = 1
for i in find:
if i in dict_card:
print(dict_card[i], end=' ')
else:
print(0, end=' ')
μλ μ΄μ§νμ -> μ°ΎμΌλ©΄ μλ€ μΈλ±μ€ νμΈν΄κ°λ©΄μ κ°μ μμλ₯Ό μ°Ύμ
μ΄λ κ² νλ €κ³ νλλ° λ³΅μ‘νκ³ λΉν¨μ¨μ μ.. λ΄κ° μκ°ν΄λ μ΄κ±΄ μλλ€ μΆμλ€
λμ λ리λ₯Ό μ΄μ©ν΄μ {κ°:κ°μ} ννλ‘ μ μ₯νκ³ κ°μ μ°ΎμΌλ©΄ κ°μλ₯Ό μΆλ ₯νκ² νλ€
μ΄μ§νμμ μ΄μ©νμ§ μμλ ν리λ λ¬Έμ λ€!