71162023-12-31 08:51:17MagyarKendeSZLGÉrdekes túra (70 pont)cpp17Wrong answer 65/7013ms8200 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 = 0, count = 0, len = 0;

    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
base65/70
1Accepted0/03ms1864 KiB
2Accepted0/013ms3224 KiB
3Accepted3/33ms2744 KiB
4Wrong answer0/33ms2856 KiB
5Partially correct2/33ms3072 KiB
6Partially correct2/33ms3296 KiB
7Accepted3/33ms3364 KiB
8Accepted3/33ms3368 KiB
9Accepted3/33ms3508 KiB
10Accepted3/33ms3852 KiB
11Accepted3/33ms3836 KiB
12Accepted3/33ms3996 KiB
13Accepted4/43ms4252 KiB
14Accepted4/48ms4924 KiB
15Accepted4/48ms5028 KiB
16Accepted4/49ms5308 KiB
17Accepted4/48ms5576 KiB
18Accepted4/410ms6028 KiB
19Accepted4/412ms6824 KiB
20Accepted4/412ms7512 KiB
21Accepted4/413ms7976 KiB
22Accepted4/410ms8200 KiB