201512026-01-03 11:53:21xxxSíkság (55)cpp17Wrong answer 35/5513ms828 KiB
#include <bits/stdc++.h>
using namespace std;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int regi = a[1], uj = a[1];
    int length = 1;
    int maxlength = 1;
    int maxi = 0, most = 1;
    for(int i = 2; i <= n; i++) {
        if(regi == uj) {
            if(abs(a[i]-uj) <= 1) {
                uj = a[i];
                length++;
            } else {
                //maxlength = max(maxlength, length);
                if (maxlength < length) {
                    maxlength = length;
                    maxi = most;
                }
                uj = regi = a[i];
                most = i;
                length = 1;
            }
        } else {
            if(a[i] != uj && a[i] != regi) {
                if (maxlength < length) {
                    maxlength = length;
                    maxi = most;
                }
                uj = regi = a[i];
                most = i;
                length = 1;
            } else {
                length++;
            }
        }
    }

    if (maxlength < length) {
        maxlength = length;
        maxi = most;
    }

    cout << maxlength << ' ' << maxi << endl;


}
SubtaskSumTestVerdictTimeMemory
base35/55
1Accepted0/01ms316 KiB
2Wrong answer0/02ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/21ms332 KiB
6Accepted2/21ms508 KiB
7Wrong answer0/31ms316 KiB
8Accepted2/21ms316 KiB
9Accepted3/31ms316 KiB
10Wrong answer0/32ms316 KiB
11Wrong answer0/32ms316 KiB
12Accepted3/32ms316 KiB
13Wrong answer0/310ms828 KiB
14Wrong answer0/38ms820 KiB
15Wrong answer0/39ms824 KiB
16Accepted3/310ms828 KiB
17Accepted3/313ms644 KiB
18Accepted3/312ms828 KiB
19Accepted3/312ms828 KiB
20Accepted3/310ms820 KiB
21Accepted3/36ms632 KiB
22Accepted3/38ms740 KiB