76372024-01-10 10:02:38BenedekMartonSíkság (55)cpp17Wrong answer 33/5535ms5200 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int t[n], m[100001], ln, lk, k=0, v=-1, maxh=1, maxi=0;
    for(int i=1; i<100001; i++)
    {
        m[i]=0;
    }
    for(int i=0; i<n; i++)
    {
        cin >> t[i];
    }
    ln=t[0];
    lk=t[0];
    while(v<n-1)
    {
        v++;
        m[t[v]]++;
        if(ln<t[v])
        {
            if(t[v]-lk>1)
            {
                if(v-k>maxh)
                {
                    maxh=v-k;
                    maxi=v;
                }
                for(k=k; m[lk]>0; k++)
                {
                    m[t[k]]--;
                }
                lk=ln;
                ln=t[v];
            }
            else
            {
                ln=t[v];
            }
        }
        else if(lk>t[v])
        {
            if(ln-t[v]>1)
            {
                if(v-k>maxh)
                {
                    maxh=v-k;
                    maxi=v;
                }
                for(k=k; m[ln]>0; k++)
                {
                    m[t[k]]--;
                }
                ln=lk;
                lk=t[v];
            }
            else
            {
                lk=t[v];
            }
        }
        //cout << k+1 << " " << v+1 << endl;
    }
    if(v-k+1>maxh)
    {
        maxh=v-k+1;
        maxi=v+1;
    }
    cout << maxh << " " << maxi-maxh+1;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base33/55
1Accepted0/03ms2644 KiB
2Accepted0/04ms3060 KiB
3Accepted2/23ms2980 KiB
4Accepted2/23ms3380 KiB
5Wrong answer0/23ms3492 KiB
6Wrong answer0/23ms3564 KiB
7Accepted3/33ms3644 KiB
8Accepted2/23ms3648 KiB
9Accepted3/33ms3928 KiB
10Accepted3/36ms3908 KiB
11Wrong answer0/34ms4116 KiB
12Accepted3/34ms4040 KiB
13Wrong answer0/334ms4776 KiB
14Accepted3/320ms4912 KiB
15Wrong answer0/327ms5068 KiB
16Wrong answer0/335ms5196 KiB
17Accepted3/335ms5196 KiB
18Wrong answer0/335ms5200 KiB
19Accepted3/335ms5076 KiB
20Accepted3/335ms5076 KiB
21Accepted3/319ms4740 KiB
22Wrong answer0/328ms5164 KiB