백준문제풀이/정렬

18870 (다시풀기)

포비용 2023. 1. 28.
import sys


sys.stdin = open("input.txt","rt")

n = int(input())

lists = list(map(int, input().split()))
copy_list = lists.copy()

lists.sort()

tmp_dic = {}

for k in lists:
    tmp_dic[k] = lists.index(k)


for j in copy_list:
    for i in tmp_dic.items():
        if j == i[0]:
            j = i[1]
            print(j, end = " ")
            
            
 --------------------------------------
 
 #수정 정답임
 
 import sys

sys.stdin = open("input.txt","rt")

n = int(input())

lists = list(map(int, input().split()))
set_lists = list(set(lists.copy()))


set_lists.sort()

new_dict = {}

for i in range(len(set_lists)):
    new_dict[set_lists[i]] = i

# print(new_dict)



for x in lists:
    print(new_dict[x], end = " ")

'백준문제풀이 > 정렬' 카테고리의 다른 글

10814  (0) 2023.01.28
1181  (0) 2023.01.26
11651  (0) 2023.01.26
11650  (0) 2023.01.26
1427  (0) 2023.01.26

댓글