211322026-01-12 12:30:02SzeredaiNatanaelSíkság (55)cpp17Wrong answer 6/5510ms1016 KiB
#include <iostream>
#include <vector>
using namespace std;

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

    int N;
    cin >> N;

    vector<int> M(N);
    for (int i = 0; i < N; i++) {
        cin >> M[i];
    }

    int bestLen = 1;
    int bestStart = 0;

    int start = 0;
    int mn = M[0], mx = M[0];

    for (int i = 1; i < N; i++) {
        mn = min(mn, M[i]);
        mx = max(mx, M[i]);

        if (mx - mn > 1) {
            // új szakasz indul
            start = i - 1;
            mn = min(M[i - 1], M[i]);
            mx = max(M[i - 1], M[i]);
        }

        int len = i - start + 1;
        if (len > bestLen) {
            bestLen = len;
            bestStart = start;
        }
    }

    cout << bestLen + 1 << " " << bestStart << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/55
1Accepted0/01ms316 KiB
2Wrong answer0/02ms316 KiB
3Wrong answer0/21ms508 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/31ms316 KiB
10Wrong answer0/32ms316 KiB
11Wrong answer0/32ms316 KiB
12Wrong answer0/32ms464 KiB
13Accepted3/310ms820 KiB
14Wrong answer0/38ms820 KiB
15Accepted3/38ms820 KiB
16Wrong answer0/310ms820 KiB
17Wrong answer0/310ms820 KiB
18Wrong answer0/310ms820 KiB
19Wrong answer0/310ms1004 KiB
20Wrong answer0/310ms1016 KiB
21Wrong answer0/36ms580 KiB
22Wrong answer0/38ms564 KiB