28992023-02-02 12:49:01UnluckYInverziócpp11Accepted 50/5061ms7980 KiB
/*
4 3 5 1 2




4 5 2 1 3

*/


#include <bits/stdc++.h>

using namespace std;

int main(){

    ios_base::sync_with_stdio(0); cin.tie(0);

    int n; cin >> n;
    vector<int> v(n+1);

    for (int i = 0; i < n; i++){
        int a; cin >> a;
        v[a] = i+1;
    }

    int mx = 0, tav = 0, i = 0, j = 0;

    for (int x : v){

        mx = max(mx, x);

        if (mx - x > tav){
            i = mx; j = x; tav = mx-x;
        }

    }

    if (tav == 0){
        cout << -1; return 0;
    }

    cout << j << " " << i;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/08ms2316 KiB
3Accepted1/13ms2228 KiB
4Accepted2/23ms2324 KiB
5Accepted7/73ms2448 KiB
6Accepted2/28ms2844 KiB
7Accepted2/257ms6840 KiB
8Accepted2/261ms6852 KiB
9Accepted2/259ms6812 KiB
10Accepted2/259ms7064 KiB
11Accepted2/259ms7276 KiB
12Accepted2/257ms7236 KiB
13Accepted2/259ms7576 KiB
14Accepted2/257ms7512 KiB
15Accepted2/257ms7508 KiB
16Accepted2/259ms7512 KiB
17Accepted2/261ms7512 KiB
18Accepted2/257ms7512 KiB
19Accepted3/357ms7768 KiB
20Accepted3/357ms7808 KiB
21Accepted2/257ms7724 KiB
22Accepted2/257ms7720 KiB
23Accepted2/259ms7768 KiB
24Accepted2/257ms7980 KiB