130652025-01-05 13:43:55fzs1969Inverziócpp11Accepted 50/50180ms2360 KiB
#include <iostream>
using namespace std;
int main()
{
    int h[500001];
    int meret, ertek, elso, masodik;
    cin >> meret;
    meret ++;
    for(int i=1; i<meret; i++)
    {
        cin >> ertek;
        h[ertek] = i;
    }
    int maximum = 0;
    int maxtav = 0;
    for(int i=1; i<meret; i++)
    {
        if(maxtav < maximum-h[i])
        {
            maxtav = maximum-h[i];
            elso = h[i];
            masodik = maximum;
        }
        if(maximum < h[i]) maximum = h[i];
    }
    if(maxtav > 0) cout << elso << " " << masodik;
    else cout << -1;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms320 KiB
2Accepted0/017ms568 KiB
3Accepted1/11ms508 KiB
4Accepted2/21ms320 KiB
5Accepted7/71ms508 KiB
6Accepted2/216ms568 KiB
7Accepted2/2171ms2168 KiB
8Accepted2/2178ms2348 KiB
9Accepted2/2180ms2352 KiB
10Accepted2/2172ms2232 KiB
11Accepted2/2174ms2360 KiB
12Accepted2/2170ms2204 KiB
13Accepted2/2172ms2360 KiB
14Accepted2/2172ms2156 KiB
15Accepted2/2171ms2104 KiB
16Accepted2/2173ms2104 KiB
17Accepted2/2172ms2152 KiB
18Accepted2/2172ms2160 KiB
19Accepted3/3171ms2356 KiB
20Accepted3/3171ms2360 KiB
21Accepted2/2170ms2160 KiB
22Accepted2/2172ms2204 KiB
23Accepted2/2173ms2340 KiB
24Accepted2/2173ms2116 KiB