19142022-12-09 23:31:06kdbSíkság (55)cpp11Wrong answer 29/5512ms4996 KiB
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>vec(n);
    for (size_t i = 0; i < n; i++) cin >> vec[i];

    int p = -1, c = vec[0], pc = 0, cc = 1, l = -1, m = 0;
    for (size_t i = 0; i < n; i++)
    {
        if (vec[i] == c) cc++;
        else if(p == vec[i])
        {
            pc += cc;
            p = c;
            c = vec[i];
            cc = 1;
        }
        else
        {
            if (l < cc + pc)
            {
                l = cc + pc;
                m = i;
            }
            pc = cc;
            p = c;
            c = vec[i];
            cc = 1;
        }
    }
    if (l < cc + pc)
    {
        l = cc + pc;
        m = n - 1;
    }
    cout << l << " " << m - l + 1 << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base29/55
1Accepted0/03ms1700 KiB
2Accepted0/03ms2036 KiB
3Wrong answer0/22ms2068 KiB
4Wrong answer0/22ms2296 KiB
5Wrong answer0/22ms2348 KiB
6Wrong answer0/22ms2724 KiB
7Accepted3/32ms2744 KiB
8Accepted2/22ms2952 KiB
9Wrong answer0/32ms3160 KiB
10Accepted3/33ms3228 KiB
11Accepted3/33ms3544 KiB
12Wrong answer0/33ms3868 KiB
13Wrong answer0/312ms4280 KiB
14Accepted3/38ms4352 KiB
15Accepted3/310ms4544 KiB
16Accepted3/312ms4484 KiB
17Wrong answer0/312ms4608 KiB
18Wrong answer0/312ms4668 KiB
19Accepted3/312ms4928 KiB
20Accepted3/312ms4996 KiB
21Accepted3/37ms4472 KiB
22Wrong answer0/39ms4480 KiB