python/백준 - 1015번 문제에 대한 분석임.
import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
l_sort = sorted(l[:])
temp = []
for i in l:
temp.append(i)
answer = l_sort.index(i)+temp.count(i)-1
print(answer, end=' ')
n = int(input())
l = list(map(int, input().split()))
l_sort = sorted(l[:])
temp = []
for i in l:
temp.append(i)
answer = l_sort.index(i)+temp.count(i)-1
print(answer, end=' ')
temp = []: 새로운 list 선언. 여기에 수열의 원소를 하나씩 넣을 예정이다.temp.append(i): for문으로 꺼내온 l의 원소를 temp list에 집어 넣는다.answer = l_sort.index(i)+temp.count(i)-1l_sort.index(i): 수열이 정렬된 list인 l_sort list의 원소 i indextemp.count(i)-1: temp list에 원소 i가 몇개인지 count한다. 이때 answer 변수에 값을 할당하기 전 이미 temp list에는 원소 i가 하나는 반드시 들어가기 때문에 -1을 해준다.