128502025-01-02 13:30:58BucsMateInverziócpp17Accepted 50/50196ms4312 KiB
#include <iostream>

using namespace std;

int sor[500001];
int poz[500001];

int main()
{
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> sor[i];
        poz[sor[i]] = i;
    }
    int max_tav = 0;
    int index2 = N;
    int megoldas_bal, megoldas_jobb;
    for(int num = N; num >= 2; num--){
        int index1 = poz[num];
        while(sor[index2] >= num && index2 > 0){
            index2--;
        }
        if(index2 > 0 && index1 < index2 && index2 - index1 > max_tav){
            max_tav = index2 - index1;
            megoldas_bal = index1;
            megoldas_jobb = index2;
        }
    }
    if(max_tav != 0){
        cout << megoldas_bal << " " << megoldas_jobb << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms320 KiB
2Accepted0/017ms632 KiB
3Accepted1/11ms320 KiB
4Accepted2/22ms320 KiB
5Accepted7/71ms320 KiB
6Accepted2/217ms772 KiB
7Accepted2/2174ms4188 KiB
8Accepted2/2180ms4220 KiB
9Accepted2/2182ms4072 KiB
10Accepted2/2178ms4272 KiB
11Accepted2/2178ms4144 KiB
12Accepted2/2173ms4248 KiB
13Accepted2/2178ms4312 KiB
14Accepted2/2177ms4296 KiB
15Accepted2/2173ms4152 KiB
16Accepted2/2190ms4148 KiB
17Accepted2/2179ms4192 KiB
18Accepted2/2196ms4092 KiB
19Accepted3/3173ms4152 KiB
20Accepted3/3174ms4292 KiB
21Accepted2/2173ms4152 KiB
22Accepted2/2178ms4152 KiB
23Accepted2/2177ms4152 KiB
24Accepted2/2172ms4152 KiB