13622022-05-23 11:02:11nkdorka1212Inverziócpp11Accepted 50/50141ms74784 KiB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define accept_plss ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back

int main()
{
    accept_plss;
    int n;
    cin>>n;
    vector<pair<int,int>>v(n);
    for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        v.pb({a,i});
    }
    sort(v.begin(),v.end());
    int maxTav=0;
    int minH=INT_MAX/2;
    int maxH=0;
    int maxi=0;
    for(pii x:v)
    {
        if(maxTav<maxi-x.se)
        {
            maxH=maxi;
            minH=x.se;
            maxTav=maxi-x.se;
        }
        if(x.se>maxi)
        {
            maxi=x.se;
        }
    }
    if(maxTav==0)
    {
        cout<<-1<<"\n";
    }else
    {
        cout<<minH<<" "<<maxH<<"\n";
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1780 KiB
2Accepted0/016ms3628 KiB
3Accepted1/11ms2192 KiB
4Accepted2/21ms2224 KiB
5Accepted7/71ms2224 KiB
6Accepted2/212ms3856 KiB
7Accepted2/290ms21264 KiB
8Accepted2/2123ms24580 KiB
9Accepted2/2133ms27900 KiB
10Accepted2/2141ms31224 KiB
11Accepted2/2123ms34544 KiB
12Accepted2/2119ms37472 KiB
13Accepted2/2119ms41112 KiB
14Accepted2/2123ms44436 KiB
15Accepted2/2104ms47756 KiB
16Accepted2/2130ms51076 KiB
17Accepted2/2130ms54392 KiB
18Accepted2/2125ms57716 KiB
19Accepted3/3103ms61040 KiB
20Accepted3/394ms64352 KiB
21Accepted2/293ms67676 KiB
22Accepted2/2127ms70996 KiB
23Accepted2/2128ms74312 KiB
24Accepted2/289ms74784 KiB