155692025-02-20 16:26:39horkaLegmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/3550ms1116 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n; cin>>n;
    vector<array<int, 2>> v(n);
    for(int i=0; i<n; i++)
    {
        cin>>v[i][0];
        v[i][1]=i;
    }
    sort(v.begin(),v.end());
    vector<int> be;
    int maxi=0,l=-1,r=-1,last=1e6;
    for(auto [ert,ind]:v)
    {
        if(last!=ert)
        {
            for(int &x:be)
                maxi=max(maxi,x);
            be.clear();
            last=ert;
        }
        if(maxi-ind>r-l || maxi-ind==r-l && ind<l) l=ind,r=maxi;
        be.push_back(ind);
    }
    if(l<0) cout<<"-1\n";
    else cout<<l+1<<" "<<r+1<<"\n";
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/01ms316 KiB
2Accepted0/050ms1076 KiB
3Accepted1/11ms508 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted1/11ms412 KiB
9Accepted1/12ms316 KiB
10Accepted1/12ms316 KiB
11Accepted1/13ms320 KiB
12Accepted2/218ms564 KiB
13Accepted2/220ms564 KiB
14Accepted2/223ms564 KiB
15Accepted2/214ms564 KiB
16Accepted2/224ms808 KiB
17Accepted2/235ms820 KiB
18Accepted2/239ms1036 KiB
19Accepted2/243ms1000 KiB
20Accepted2/246ms1116 KiB
21Accepted2/248ms1076 KiB
22Accepted2/250ms1076 KiB
23Accepted2/237ms1076 KiB
24Accepted2/239ms1076 KiB