121682024-12-06 07:44:23KissCsongor777Inverziócpp11Accepted 50/50190ms2360 KiB
#include<bits/stdc++.h>

using namespace std;

int H[500001];

int main()
{
    int N, x, m=-2147483647,a=0,b,d;
    cin>>N;
    for(int i=1; i<=N; i++)
    {
        cin>>x;
        H[x]=i;
    }
    x=1;
    for(int i=2; i<=N; i++)
    {
        if(H[i]<H[x])
        {
            d=H[x]-H[i]; if(d>m){m=d; a=H[i]; b=H[x];}}
        else x=i;

    }
    if(a!=0)cout<<a<<" "<<b;
    else cout<<-1;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms332 KiB
2Accepted0/017ms568 KiB
3Accepted1/11ms320 KiB
4Accepted2/21ms320 KiB
5Accepted7/71ms320 KiB
6Accepted2/216ms608 KiB
7Accepted2/2170ms2124 KiB
8Accepted2/2175ms2332 KiB
9Accepted2/2177ms2360 KiB
10Accepted2/2190ms2224 KiB
11Accepted2/2172ms2360 KiB
12Accepted2/2170ms2112 KiB
13Accepted2/2172ms2104 KiB
14Accepted2/2172ms2160 KiB
15Accepted2/2171ms2360 KiB
16Accepted2/2173ms2360 KiB
17Accepted2/2173ms2164 KiB
18Accepted2/2172ms2104 KiB
19Accepted3/3171ms2352 KiB
20Accepted3/3171ms2360 KiB
21Accepted2/2170ms2360 KiB
22Accepted2/2173ms2200 KiB
23Accepted2/2175ms2324 KiB
24Accepted2/2170ms2360 KiB