逆序对,把其中一个改成0,问改哪个获得的逆序对最少,以及最终多少个逆序对。
时间超了。
import copy
n =int(input())
li = [int(x) for x in input().split()]
count_list=[]
for i in range(n):
n1=copy.deepcopy(li)
n1[i]=0
count=0
for j in range(n):
for k in range(j+1,n):
# print(n1[j],n1[k])
if n1[j]>n1[k]:
count+=1
count_list.append(count)
print(min(count_list), count_list.index(min(count_list))+1)