49432023-04-07 17:13:37eokorLegmesszebbi rossz sorrendű (35 pont)cpp11Runtime error 0/35263ms6972 KiB
#include <bits/stdc++.h>

using namespace std;

int csokk(pair<int,int> a,pair<int,int> b){
        return a.first>b.first;
}

int main()
{
//    ifstream cin("be.txt");
   int n;
   cin>>n;
   vector <pair<int,int>> sori(n+1);
   for(int i=1;i<=n;i++)
        {
            cin>>sori[i].first;
            sori[i].second=i;
        }
    sort(sori.begin()+1,sori.end()+1,csokk);
    vector <pair<int,int>> maxi;
    maxi.push_back({0,0});
    maxi.push_back({sori[n].first,sori[n].second});
    vector <pair<int,int>> mini;
    mini.push_back({0,0});
    mini.push_back({sori[1].first,sori[1].second});

    int akmini,akmaxi;
    akmaxi=sori[n].second;
    akmini=sori[1].second;
//    cout<<akmaxi<<" "<<akmini<<endl;

        for(int i=n-1;i>=0;i--)
        {
        if(akmaxi<sori[i].second)
            {
                maxi.push_back({sori[i].first,sori[i].second});
                akmaxi=sori[i].second;

            }
        }
        for(int i=2;i<=n;i++)
        {
            if(akmini>sori[i].second)
                {
                mini.push_back({sori[i].first,sori[i].second});
                akmini=sori[i].second;
                }
        }
//        for(int i=1;i<=maxi.size()-1;i++)
//            cout<<maxi[i].second<<" ";
//        cout<<endl;
//        for(int i=1;i<=mini.size()-1;i++)
//            cout<<mini[i].second<<" ";
    int minihossz=mini.size()-1;
    int maxihossz=maxi.size()-1;
    int v1=0,v2=0;
        for(int i=minihossz;i>=1;i--)
        {
            int ind=1;
            while(ind<=maxihossz)
            {
                if(mini[i].first>maxi[ind].first)
                {
                    if(v1-v2<maxi[ind].second-mini[i].second)
                    {
                        v1=maxi[ind].second;
                        v2=mini[i].second;
                    }
                }
                ind++;
            }

        }
    cout<<v2<<" "<<v1;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/35
1Runtime error0/03ms1788 KiB
2Wrong answer0/050ms3336 KiB
3Runtime error0/13ms2156 KiB
4Runtime error0/13ms2424 KiB
5Runtime error0/13ms2328 KiB
6Runtime error0/13ms2580 KiB
7Runtime error0/13ms2852 KiB
8Runtime error0/13ms3016 KiB
9Runtime error0/14ms3236 KiB
10Runtime error0/14ms3476 KiB
11Runtime error0/14ms3692 KiB
12Wrong answer0/219ms4224 KiB
13Wrong answer0/223ms4580 KiB
14Wrong answer0/224ms4824 KiB
15Wrong answer0/216ms4420 KiB
16Wrong answer0/225ms4860 KiB
17Wrong answer0/235ms4704 KiB
18Wrong answer0/239ms5148 KiB
19Wrong answer0/243ms5092 KiB
20Wrong answer0/246ms5092 KiB
21Wrong answer0/248ms5388 KiB
22Wrong answer0/250ms5692 KiB
23Time limit exceeded0/2246ms6884 KiB
24Time limit exceeded0/2263ms6972 KiB