131002025-01-06 14:32:10lacitoInverziócpp17Időlimit túllépés 12/50600ms2540 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> s(n + 1);
    int maxdist = 0, maxi = -1, maxj = -1;
    for (int i = 1; i <= n; i++) cin >> s[i];
    for (int i = 1; i <= n; i++) {
        for (int j = n; j > i; j--) {
            if (s[j] < s[i]) {
                if (j - i > maxdist) {
                    maxdist = j - i;
                    maxi = i;
                    maxj = j;
                }
                break;
            }
        }
    }
    if (maxdist > 0) cout << maxi << " " << maxj << "\n";
    else cout << "-1\n";
    return 0;
}
/*
5
4 3 5 1 2
*/
RészfeladatÖsszpontTesztVerdiktIdőMemória
base12/50
1Elfogadva0/01ms316 KiB
2Időlimit túllépés0/0512ms568 KiB
3Elfogadva1/11ms316 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva7/71ms316 KiB
6Elfogadva2/2300ms564 KiB
7Időlimit túllépés0/2600ms2356 KiB
8Időlimit túllépés0/2600ms2356 KiB
9Időlimit túllépés0/2583ms2356 KiB
10Időlimit túllépés0/2587ms2540 KiB
11Időlimit túllépés0/2588ms2356 KiB
12Időlimit túllépés0/2600ms2100 KiB
13Időlimit túllépés0/2588ms2356 KiB
14Időlimit túllépés0/2583ms2356 KiB
15Időlimit túllépés0/2582ms2356 KiB
16Időlimit túllépés0/2600ms2356 KiB
17Időlimit túllépés0/2586ms2356 KiB
18Időlimit túllépés0/2578ms2356 KiB
19Időlimit túllépés0/3587ms2368 KiB
20Időlimit túllépés0/3582ms2356 KiB
21Időlimit túllépés0/2587ms2356 KiB
22Időlimit túllépés0/2586ms2356 KiB
23Időlimit túllépés0/2577ms2540 KiB
24Időlimit túllépés0/2600ms2356 KiB