127652024-12-30 09:54:39birozsInverziópython3Wrong answer 34/50361ms61784 KiB
N = int(input())
lista = list(map(int,input().split()))
#N = 15
#lista = [4,2,3,1,5,6,7,8,11,12,9,13,10,14,15]
#lista = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
#elter = [3,0,0,3,0,0,0,0,2,2,2,1,3,0,0]
maxelter = 0
maxelterpoz = []
maxertek = 0
for i in range(N):
    if abs(lista[i] - (i+1)) >= maxelter and lista[i] != i+1:
        if abs(lista[i] - (i+1)) > maxelter:
            maxelterpoz = []
            maxelter = abs(lista[i] - (i+1))
        maxelterpoz.append(i+1)          
#print(maxelterpoz)
if maxelter == 0:
    print(-1)
else:
    maxertek = 0
    for x in maxelterpoz:
        if lista[x-1] > x:
            minelterpoz = N
            for i in range(N-1,-1,-1):
                if lista[i] < lista[x-1]:
                    minelterpoz = i+1
                    break
            #print(x,minelterpoz)
            if minelterpoz - x > maxertek:
                maxertek = minelterpoz - x
                vegemin = x
                vegemax = minelterpoz
        else:
            minelterpoz = 1
            for i in range(N):
                if lista[i] > lista[x-1]:
                    minelterpoz = i+1
                    break
            #print(minelterpoz,x)
            if x - minelterpoz > maxertek:
                maxertek = x - minelterpoz
                vegemin = minelterpoz
                vegemax = x
    print(vegemin,vegemax)




SubtaskSumTestVerdictTimeMemory
base34/50
1Accepted0/017ms3116 KiB
2Accepted0/050ms8844 KiB
3Accepted1/116ms3120 KiB
4Wrong answer0/217ms3124 KiB
5Accepted7/717ms3128 KiB
6Wrong answer0/245ms8808 KiB
7Accepted2/2317ms61680 KiB
8Accepted2/2310ms61572 KiB
9Wrong answer0/2319ms61700 KiB
10Wrong answer0/2312ms61784 KiB
11Wrong answer0/2316ms61684 KiB
12Wrong answer0/2291ms60552 KiB
13Accepted2/2356ms61664 KiB
14Accepted2/2331ms61632 KiB
15Accepted2/2345ms61628 KiB
16Accepted2/2349ms61636 KiB
17Wrong answer0/2312ms61640 KiB
18Accepted2/2333ms61628 KiB
19Accepted3/3351ms61628 KiB
20Accepted3/3361ms61780 KiB
21Accepted2/2335ms61584 KiB
22Accepted2/2331ms61632 KiB
23Wrong answer0/2310ms61632 KiB
24Accepted2/2321ms61632 KiB