71172023-12-31 08:53:15MagyarKendeSZLGÉrdekes túra (70 pont)cpp17Accepted 70/7013ms4092 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;
using ll = long long;
using point = array<int, 2>;

int main() {
    speed;

    int N;
    cin >> N;
    vector<int> v(N);
    cinv(v);

    int l = 0, r = 1, count = 0, len = 0;

    while (r < N && v[l] == v[r]) {
        l++;
        r++;
    }

    while (r < N) {
        if ((r + 1 == N || v[r + 1] == v[r]) && r - l + 1 >= 2) {
            len = max(len, r - l + 1);
            count++;
            r += 2;
            l = r - 1;
            while (r < N && v[l] == v[r]) {
                l++;
                r++;
            }
        } else {
            r++;
        }
    }

    cout << count << '\n' << (count ? len : -1);
}
SubtaskSumTestVerdictTimeMemory
base70/70
1Accepted0/03ms1828 KiB
2Accepted0/012ms2876 KiB
3Accepted3/33ms2128 KiB
4Accepted3/33ms2340 KiB
5Accepted3/33ms2544 KiB
6Accepted3/33ms2756 KiB
7Accepted3/33ms2836 KiB
8Accepted3/33ms2836 KiB
9Accepted3/33ms2840 KiB
10Accepted3/33ms2848 KiB
11Accepted3/33ms3068 KiB
12Accepted3/33ms3072 KiB
13Accepted4/43ms3072 KiB
14Accepted4/48ms3224 KiB
15Accepted4/48ms3348 KiB
16Accepted4/48ms3348 KiB
17Accepted4/48ms3348 KiB
18Accepted4/49ms3692 KiB
19Accepted4/412ms3956 KiB
20Accepted4/412ms4068 KiB
21Accepted4/413ms3964 KiB
22Accepted4/410ms4092 KiB