201502026-01-03 11:51:08xxxSíkság (55)cpp17Wrong answer 30/5513ms836 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++;
            }
        }
    }

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


}
SubtaskSumTestVerdictTimeMemory
base30/55
1Accepted0/01ms508 KiB
2Wrong answer0/02ms316 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/21ms416 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/31ms316 KiB
8Accepted2/21ms316 KiB
9Accepted3/32ms512 KiB
10Wrong answer0/33ms316 KiB
11Wrong answer0/32ms316 KiB
12Wrong answer0/33ms316 KiB
13Wrong answer0/312ms828 KiB
14Wrong answer0/38ms828 KiB
15Wrong answer0/39ms824 KiB
16Accepted3/312ms820 KiB
17Accepted3/313ms836 KiB
18Accepted3/312ms824 KiB
19Accepted3/313ms828 KiB
20Accepted3/312ms824 KiB
21Accepted3/37ms564 KiB
22Accepted3/39ms756 KiB