
시간초과났던 풀이
n = int(input())
arr = list(map(int,input().split()))
s = sorted(set(arr))
ans = []
for i in arr:
ans.append(s.index(i))
print(*ans)
시간초과 해결 위해 딕셔너리 이용해서 풀이
n = int(input())
arr = list(map(int,input().split()))
s = sorted(arr)
dic = {}
cnt = 0
ans = []
for i in range(len(arr)):
if s[i] not in dic:
dic[s[i]]= cnt
cnt += 1
for i in arr:
ans.append(dic[i])
print(*ans)
풀리긴 하는데 좀 오래걸리는 것 같기도 하다..
| [파이썬/python] 백준 13241번 : 최소공배수 (🥈5) (유클리드호제법) (0) | 2023.03.28 |
|---|---|
| [파이썬/python] 백준 1934번 : 최소공배수 (🥉1) (유클리드호제법) (0) | 2023.03.27 |
| [파이썬/python] 백준 25305번 : 커트라인(🥉2) (0) | 2023.03.27 |
| [파이썬/python] 백준 19532번 : 수학은 비대면강의입니다 (🥉2) (브루트포스) (0) | 2023.03.27 |
| [파이썬/python] 프로그래머스 : 카펫 (Lv.2) (브루트포스) (0) | 2023.03.27 |