94982024-02-22 12:16:19Vkrisztian01Legmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/3557ms7140 KiB
#include <iostream>
#include<queue>

using namespace std;

int main()
{
    int n,meret,eleje=0,vege=0,index;
    cin>>n;
    meret=n;
    int nums[n+1];
    bool volte[n+1];
    priority_queue<pair<int,int> > seged;
    for(int i=1;i<=n;i++)
    {
        cin>>nums[i];
        volte[i]=false;
        seged.push(make_pair(nums[i],i));
    }
    while(!seged.empty())
    {
        index=seged.top().second;
        seged.pop();
        volte[index]=true;
        if(index!=meret && meret-index>=vege-eleje)
        {
            eleje=index;
            vege=meret;
        }
        while(volte[meret])--meret;
    }
    if(eleje==0)
    {
        cout<<-1;
        return 0;
    }
    cout<<eleje<<" "<<vege;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1680 KiB
2Accepted0/057ms5144 KiB
3Accepted1/13ms2076 KiB
4Accepted1/13ms2284 KiB
5Accepted1/13ms2680 KiB
6Accepted1/12ms2516 KiB
7Accepted1/13ms2452 KiB
8Accepted1/13ms2596 KiB
9Accepted1/13ms2844 KiB
10Accepted1/14ms2832 KiB
11Accepted1/14ms2740 KiB
12Accepted2/224ms4376 KiB
13Accepted2/227ms4616 KiB
14Accepted2/228ms4836 KiB
15Accepted2/217ms4312 KiB
16Accepted2/228ms5040 KiB
17Accepted2/241ms6396 KiB
18Accepted2/246ms6304 KiB
19Accepted2/252ms6664 KiB
20Accepted2/252ms6756 KiB
21Accepted2/257ms7056 KiB
22Accepted2/257ms7140 KiB
23Accepted2/248ms7008 KiB
24Accepted2/248ms7012 KiB