142022025-01-10 09:02:13TundeSíkság (55)cpp17Wrong answer 50/5534ms784 KiB
#include <iostream>

using namespace std;

int main()
{
    int n, k=-1, mh=-1, jh=0, v=-1, a=-1, b=-1, db=0;
    cin >> n;
    int t[n];
    for(int i=0; i<n; i++)
    {
        cin >> t[i];
        if(i!=0)
        {
            if((t[i]-t[i-1]==1 || t[i]-t[i-1]==-1) || t[i]==t[i-1])
            {
                if(t[i]==t[i-1])
                {
                    jh++;
                    db++;
                }
                else
                {
                    if((b==-1 || b==t[i]) || a==t[i])
                    {
                        if(b==-1 && a!=t[i])
                        {
                            b=t[i];
                        }
                        jh++;
                    }
                    else
                    {
                        b=t[i];
                        a=t[i-1];
                        jh=2+db;
                    }
                    db=0;
                }
            }
            else
            {
                jh=1;
                a=t[i];
                b=-1;
                db=0;
            }
        }
        else
        {
            a=t[0];
            jh++;
            v=0;
        }
        if(i==n-1 && jh>mh)
            mh=jh;
        if(jh>mh)
        {
            mh=jh;
            v=i;
        }
    }
    cout << mh << " " << v+1-mh+1;
}
SubtaskSumTestVerdictTimeMemory
base50/55
1Accepted0/01ms316 KiB
2Accepted0/03ms316 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted3/31ms500 KiB
8Accepted2/21ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/34ms316 KiB
11Accepted3/33ms316 KiB
12Wrong answer0/33ms508 KiB
13Accepted3/332ms640 KiB
14Accepted3/317ms756 KiB
15Accepted3/326ms776 KiB
16Accepted3/332ms560 KiB
17Accepted3/334ms564 KiB
18Accepted3/334ms768 KiB
19Accepted3/334ms600 KiB
20Accepted3/334ms560 KiB
21Accepted3/317ms784 KiB
22Accepted3/327ms596 KiB