183332025-10-20 15:42:32algoproInverziópypy3Accepted 50/50181ms73196 KiB
# UUID: dbe5f21c-1c74-4292-a54f-134fd7ab6c81
import sys
input = sys.stdin.readline

def solv():
    N = int(input())
    B=list(map(int,input().split()))
    A=[0]*(N+1)
    #A=[(B[i],i) for i in range(N)]
    #A.sort()
    for i in range(N):
        A[B[i]]=i
    a=b=0
    leghatso=0
    for i in range(N):
        #cur,index=A[i]
        index=A[i+1]
        if index < leghatso:
            if leghatso-index>b-a:
                b=leghatso
                a=index
        leghatso=max(leghatso,index)

    if a==b:
        print(-1)
    else:
        print(a+1,b+1) 

solv()
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/039ms19432 KiB
2Accepted0/059ms27112 KiB
3Accepted1/143ms19380 KiB
4Accepted2/248ms21112 KiB
5Accepted7/748ms21228 KiB
6Accepted2/257ms27124 KiB
7Accepted2/2174ms72996 KiB
8Accepted2/2155ms73172 KiB
9Accepted2/2179ms72948 KiB
10Accepted2/2152ms73136 KiB
11Accepted2/2181ms73184 KiB
12Accepted2/2177ms72500 KiB
13Accepted2/2151ms72952 KiB
14Accepted2/2150ms73016 KiB
15Accepted2/2178ms73024 KiB
16Accepted2/2152ms72936 KiB
17Accepted2/2150ms72972 KiB
18Accepted2/2177ms73092 KiB
19Accepted3/3174ms73196 KiB
20Accepted3/3150ms73008 KiB
21Accepted2/2149ms73184 KiB
22Accepted2/2177ms73052 KiB
23Accepted2/2152ms73188 KiB
24Accepted2/2144ms72944 KiB