148522025-02-04 17:23:09csdavidLegmesszebbi rossz sorrendű (35 pont)cpp17Wrong answer 25/3546ms1164 KiB
#include <iostream>
#include <algorithm>

using namespace std;

struct s{
    int szam, ind;
};

bool alma(s x1, s x2){
    if(x1.szam==x2.szam) return x1.ind>x2.ind;
    else return x1.szam<x2.szam;
}

int main()
{
    int n;
    cin >> n;
    s a[n];
    for(int i=0; i<n; i++){
        cin >> a[i].szam;
        a[i].ind=i;
    }
    int maxd=0, maxind=-1, m1=-1, m2=-1;
    sort(a, a+n, alma);
    for(int i=0; i<n; i++){
        /*while(i!=n-1&&a[i].szam==a[i+1].szam){
            i++;
        }*/
        //cout << "szam: " << a[i].szam << "\nind:" << a[i].ind << "\nmaxind: " << maxind << "\n\n";
        if(maxind>a[i].ind&&maxd<maxind-a[i].ind){
            maxd=maxind-a[i].ind;
            m1=a[i].ind+1;
            m2=maxind+1;
            //cout << m1 << ' ' << m2<< "\nmaxd: " << maxd << "\n\n";
        }
        if(a[i].ind>maxind){
            maxind=a[i].ind;
        }
    }
    if(m1!=-1) cout << m1 << ' ' << m2 << '\n';
    else cout << -1 << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base25/35
1Accepted0/01ms316 KiB
2Accepted0/046ms1076 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted1/11ms316 KiB
9Accepted1/11ms316 KiB
10Accepted1/12ms412 KiB
11Accepted1/12ms316 KiB
12Wrong answer0/217ms564 KiB
13Wrong answer0/219ms516 KiB
14Wrong answer0/220ms712 KiB
15Wrong answer0/213ms492 KiB
16Wrong answer0/221ms772 KiB
17Accepted2/232ms856 KiB
18Accepted2/237ms812 KiB
19Accepted2/241ms964 KiB
20Accepted2/241ms852 KiB
21Accepted2/246ms1164 KiB
22Accepted2/246ms1076 KiB
23Accepted2/237ms988 KiB
24Accepted2/237ms1020 KiB