λ¬Έμ
https://www.acmicpc.net/problem/18870
νμ΄
# λ°±μ€ 18870λ² λ¬Έμ - μ’ν μμΆ
n = int(input())
x = list(map(int, input().split()))
new_x = list(sorted(set(x)))
dict = {new_x[i]: i for i in range(len(new_x))}
for i in x:
print(dict[i], end=" ")
맨 μ²μ μκ°μ΄κ³Όκ° λ μ μκ°λ³΅μ‘λλ₯Ό μκ°νμλ€.
Nμ΄λΌλ μ«μκ° 100λ§μ΄κΈ° λλ¬Έμ μκ°λ³΅μ‘λλ₯Ό λ¨Όμ μκ°νμ΄μΌ νλλ° νμ§ λͺ»νλ€.
index(i)λ μκ°λ³΅μ‘λκ° O(n)μ΄κ³ λμ λ리λ O(1) μ΄λ―λ‘ λμ λ리λ₯Ό μ¬μ©ν΄μΌ νλ€.
'ποΈ Algorithm > π© λ°±μ€' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
π© [λ°±μ€] [Python] 1182λ²_λΆλΆμμ΄μ ν© (0) | 2022.11.07 |
---|---|
π© [λ°±μ€] [Python] [Class3] 1074λ²_Z (0) | 2022.11.07 |
π© [λ°±μ€] [Python] [Class3] 11724λ²_μ°κ²° μμμ κ°μ (0) | 2022.11.07 |
π© [λ°±μ€] [Python] [Class3] 1927λ²_μ΅λ ν (0) | 2022.11.07 |
π© [λ°±μ€] [Python] [ꡬν] 2167λ²_2μ°¨μ λ°°μ΄μ ν© (0) | 2022.11.06 |