Skip to content

Commit f34dfe0

Browse files
authored
[BOJ] 1015 수열 정렬 (S4)
1 parent 8cf0e31 commit f34dfe0

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

김지호/5주차/260130.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
import copy
3+
from collections import deque, defaultdict
4+
from typing import List
5+
import math
6+
7+
sys.stdin = open('../../../input.txt', 'r')
8+
9+
N = int(input())
10+
array = list(map(int,input().split(" ")))
11+
12+
# A를 오름차순으로 정렬하여 작은 숫자부터 순서대로 정리된 새로운 list를 할당
13+
sorted_A = [i for i in array]
14+
sorted_A.sort()
15+
16+
P = []
17+
# A의 각 숫자들에 대해 sorted_A에서의 index를 찾아 몇번째로 작은 숫자인지 P 수열에 새롭게 append함.
18+
for i in array:
19+
P.append(sorted_A.index(i))
20+
# 이미 할당한 숫자는 sorted_A에서 -1로 대채해 재탐색되지 않도록 함.a
21+
sorted_A[sorted_A.index(i)] = -1
22+
23+
results = [i for i in P]
24+
25+
print(" ".join(map(str,results)))

0 commit comments

Comments
 (0)