211732026-01-12 16:37:17hunzombiSíkság (55)cpp17Wrong answer 28/5534ms1452 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a;
    vector<int> visited(100001, 0);
    for (int i=0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }
    int best = -1;
    int best_i = -1;
    int low = 0, high = 0, cnt = 0;
    while (high < n) {
        while (cnt < 3 && high < n) {
            if (visited[a[high]]++ == 0) {
                cnt++;
            }
            high++;
        }
        if (high - low > best) {
            best = high - low - 1;
            best_i = low + 1;
        }
        while (cnt > 2) {
            visited[a[low]]--;
            if (visited[a[low]] == 0) {
                cnt--;
            }
            low++;
        }
    }
    cout << best << ' ' << best_i << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base28/55
1Accepted0/01ms564 KiB
2Accepted0/04ms820 KiB
3Wrong answer0/21ms564 KiB
4Wrong answer0/21ms564 KiB
5Wrong answer0/21ms564 KiB
6Accepted2/21ms564 KiB
7Wrong answer0/31ms564 KiB
8Accepted2/22ms996 KiB
9Wrong answer0/32ms564 KiB
10Accepted3/34ms820 KiB
11Accepted3/33ms1080 KiB
12Wrong answer0/33ms864 KiB
13Wrong answer0/332ms1452 KiB
14Accepted3/318ms1368 KiB
15Accepted3/325ms1200 KiB
16Accepted3/332ms1420 KiB
17Wrong answer0/334ms1388 KiB
18Wrong answer0/334ms1200 KiB
19Accepted3/334ms1416 KiB
20Accepted3/334ms1432 KiB
21Accepted3/317ms1112 KiB
22Wrong answer0/327ms1200 KiB