50822023-04-15 16:44:49AncsaLegmesszebbi rossz sorrendű (35 pont)cpp11Wrong answer 22/35282ms4544 KiB
#include <bits/stdc++.h>
//Nemes Tihamer orszagos feladat
//Tesztelheto
//https://njudge.hu/problemset/main/NT23_Legmesszebbi/

using namespace std;
/*
be
10
7 2 4 17 6 5 10 10 18 19
ki
i 6
*/

/*
be
12
2 4 7 11 9 6 3 2 8 4 6 10

ki
3 11

*/


int main()
{
    srand(time(0));
    int n;
    cin>>n;
    vector<int> a(n);
    int eleje=0, vege=0,uj;
    bool novekvo=true;
    for(int i=0;i<n;i++)
    {
        cin>>a.at(i);
  /*      if (i<n/2)
           a.at(i)=rand()%500;
        else
           a.at(i)=rand()%1000;*/
        if(a.at(i)<a.at(0))
        {
            vege=i;
        }
        if (i!=0 && novekvo && a.at(i)<a.at(i-1))
            novekvo=false;
    }
    if (novekvo)
    {
        cout<<-1;

    }
    int kicsi=a.at(0);
/*
    for(int i=0;i<n;i++)
    {
        cout<<a.at(i)<<"\t";
        if(i%10==9)
            cout<<endl;
    }
*/
    int tav=vege;
    //cout<<vege<<endl;
    for(int i=1;i<n-tav;i++)
    {
        int j=n-1;
        bool talalt=false;
        //cout<<"kicsi:"<<kicsi<<endl;
        if (a.at(i)>kicsi)
        {
           kicsi=a.at(i);
           while(j>=i+tav+1 && !talalt)
           {
//              cout<<"lepes:"<<i<<" "<<j<<" "<<tav<<endl;
              if(a.at(j)<a.at(i))
              {
                eleje=i;
                vege=j;
                tav=j-i;
                talalt=true;

        //        cout<<eleje<<" "<<vege<<endl;
              }
              j--;
           }
        }
    }

    cout << eleje+1<<" "<<vege+1 << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base22/35
1Accepted0/03ms1808 KiB
2Accepted0/0136ms2700 KiB
3Wrong answer0/13ms2216 KiB
4Accepted1/12ms2304 KiB
5Accepted1/13ms2424 KiB
6Accepted1/12ms2508 KiB
7Accepted1/12ms2512 KiB
8Accepted1/13ms2644 KiB
9Accepted1/14ms2992 KiB
10Accepted1/14ms2956 KiB
11Accepted1/16ms3092 KiB
12Time limit exceeded0/2202ms3460 KiB
13Time limit exceeded0/2254ms3544 KiB
14Time limit exceeded0/2282ms2796 KiB
15Accepted2/2116ms3484 KiB
16Time limit exceeded0/2256ms2640 KiB
17Accepted2/270ms3568 KiB
18Accepted2/287ms3788 KiB
19Accepted2/2105ms4012 KiB
20Accepted2/2109ms4228 KiB
21Accepted2/2130ms4440 KiB
22Accepted2/2136ms4544 KiB
23Time limit exceeded0/2254ms3704 KiB
24Time limit exceeded0/2263ms3800 KiB