18732022-12-06 20:43:58kovacs.peter.18fSíkság (55)cpp11Wrong answer 36/5513ms5424 KiB
#include <iostream>
#include <vector>

using namespace std;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector<int> heightS(N), countS(100001);
    int different = 0, max_begin = 0, max_end = 0;
    for (int l = 0, r = 0; r < N; r++) { // zárt intervallum
        cin >> heightS[r];
        if (++countS[heightS[r]] == 1) {
            ++different;
        }
        while (different == 3) {
            --countS[heightS[l]];
            if (countS[heightS[l]] == 0) {
                --different;
            }
            ++l;
        }
        if (r - l > max_end - max_begin) {
            max_begin = l;
            max_end = r;
        }
    }
    cout << max_end - max_begin + 1 << " " << max_begin + 1 << '\n';
}
SubtaskSumTestVerdictTimeMemory
base36/55
1Accepted0/03ms2516 KiB
2Accepted0/03ms2856 KiB
3Wrong answer0/23ms2924 KiB
4Accepted2/22ms3120 KiB
5Wrong answer0/22ms3320 KiB
6Accepted2/22ms3524 KiB
7Accepted3/32ms3600 KiB
8Accepted2/22ms3600 KiB
9Wrong answer0/32ms3728 KiB
10Accepted3/33ms3808 KiB
11Accepted3/33ms3808 KiB
12Accepted3/33ms3804 KiB
13Wrong answer0/313ms4708 KiB
14Accepted3/39ms4916 KiB
15Accepted3/310ms4992 KiB
16Accepted3/313ms5088 KiB
17Wrong answer0/312ms5164 KiB
18Wrong answer0/313ms5424 KiB
19Accepted3/312ms5368 KiB
20Accepted3/312ms5368 KiB
21Accepted3/38ms4848 KiB
22Wrong answer0/39ms5240 KiB