152792025-02-17 21:40:33antiLegmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/3548ms1176 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct szam{
    int ert, ind;
};

bool comp(szam a, szam b){
    if(a.ert != b.ert){
        return a.ert < b.ert;
    }else{
        return a.ind < b.ind;
    }
}

int main() {
    int n;
    cin >> n;
    szam t[n];
    for(int i=0; i<n; i++){
        cin >> t[i].ert;
        t[i].ind = i;
    }
    sort(t, t+n, comp);

    int maxind = t[0].ind, maxd = 0, m1 = -1, m2;
    for(int i=1; i<n; i++){
        if(maxind > t[i].ind && maxd < maxind - t[i].ind){
            m1 = maxind+1;
            m2 = t[i].ind+1;
            maxd = maxind - t[i].ind;
        }
        if(t[i].ind > maxind){
            maxind = t[i].ind;
        }
    }
    if(m1==-1) cout << -1;
    else cout << m2 << " " << m1 << endl;
}


SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/01ms316 KiB
2Accepted0/048ms1072 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted1/11ms316 KiB
9Accepted1/12ms316 KiB
10Accepted1/12ms316 KiB
11Accepted1/13ms500 KiB
12Accepted2/217ms712 KiB
13Accepted2/220ms612 KiB
14Accepted2/221ms592 KiB
15Accepted2/214ms496 KiB
16Accepted2/223ms672 KiB
17Accepted2/234ms948 KiB
18Accepted2/241ms928 KiB
19Accepted2/243ms888 KiB
20Accepted2/243ms860 KiB
21Accepted2/248ms1060 KiB
22Accepted2/248ms1176 KiB
23Accepted2/239ms1128 KiB
24Accepted2/239ms1136 KiB