140512025-01-09 17:59:13BalintInverziócpp17Accepted 50/5059ms2548 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin >> n;
    vector<int> v(n+1);
    for(int i = 0; i < n; i++)
    {
        int index;cin >> index;
        v[index] = i+1;
    }
    int maxI = -1;int maxGap = -1; int maxOut = -1;
    for(int i = 1; i <= n; i++)
    {
        if(v[i] > maxI) maxI = v[i];
        else
        {
            int inverz = maxI - v[i];
            if(maxGap < inverz)
            {
                maxGap = inverz;
                maxOut = maxI;
            }
        }
    }

    if(maxOut == -1)
    {
        cout << -1;
    }
    else
    {
        cout << maxOut - maxGap << " " << maxOut;
    }
    return 0;

    // 5
    // 4 3 5 1 2
    // 4 5 2 1 3

}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/06ms564 KiB
3Accepted1/11ms316 KiB
4Accepted2/21ms316 KiB
5Accepted7/71ms316 KiB
6Accepted2/26ms564 KiB
7Accepted2/254ms2380 KiB
8Accepted2/257ms2356 KiB
9Accepted2/259ms2356 KiB
10Accepted2/257ms2356 KiB
11Accepted2/259ms2356 KiB
12Accepted2/256ms2356 KiB
13Accepted2/257ms2356 KiB
14Accepted2/256ms2356 KiB
15Accepted2/254ms2356 KiB
16Accepted2/257ms2548 KiB
17Accepted2/257ms2148 KiB
18Accepted2/257ms2360 KiB
19Accepted3/356ms2356 KiB
20Accepted3/354ms2208 KiB
21Accepted2/256ms2356 KiB
22Accepted2/256ms2356 KiB
23Accepted2/257ms2540 KiB
24Accepted2/254ms2356 KiB