197222025-12-19 20:13:40algoproInverziócpp17Wrong answer 4/50188ms4344 KiB
// UUID: e7145199-f462-44cc-ad49-b16809d63ab3
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    vector<int> hisztogram(N+1, 0);
    vector<int> V(N+1);
    for(int i=1; i<=N; i++)
    {
        int a;
        cin>>a;
        V[i]=a;
        hisztogram[a-1]=i;
    }
    /*for(int i=0; i<=N; i++) cout<<hisztogram[i]<<" ";
    cout<<endl;*/
    
    for(int i=N-2; i>=1; i--)
    {
        hisztogram[i]=min(hisztogram[i], hisztogram[i+1]);
    }
    int maxi=-1;
    int maxis;
    for(int i=1; i<=N; i++)
    {
        if(i-hisztogram[V[i]]>maxi)
        {
             maxi=i-hisztogram[V[i]];
             maxis=i;
        }
    }
    /*for(int i=0; i<=N; i++) cout<<hisztogram[i]<<" ";
    cout<<endl;*/
    if(maxi==-1) cout<<-1;
    else cout<<maxis-maxi<<" "<<maxis;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/01ms316 KiB
2Wrong answer0/017ms748 KiB
3Wrong answer0/11ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/71ms316 KiB
6Wrong answer0/217ms804 KiB
7Wrong answer0/2179ms4332 KiB
8Wrong answer0/2187ms4148 KiB
9Accepted2/2186ms4148 KiB
10Wrong answer0/2185ms4328 KiB
11Wrong answer0/2185ms4164 KiB
12Wrong answer0/2180ms4148 KiB
13Wrong answer0/2182ms4152 KiB
14Wrong answer0/2180ms4148 KiB
15Wrong answer0/2177ms4148 KiB
16Wrong answer0/2187ms4336 KiB
17Wrong answer0/2180ms4108 KiB
18Wrong answer0/2182ms4148 KiB
19Wrong answer0/3177ms4148 KiB
20Wrong answer0/3179ms4332 KiB
21Wrong answer0/2177ms4332 KiB
22Wrong answer0/2188ms4344 KiB
23Wrong answer0/2182ms4148 KiB
24Wrong answer0/2177ms4328 KiB