205242026-01-07 17:21:39algoproSíkság (55)cpp17Wrong answer 35/5532ms832 KiB
// UUID: baf9d1a7-3d68-44a3-a491-dce7afcf7dd4
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n; cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }

    int big = -1;
    int small = nums[0];
    int start = 0;
    int len = 0;
    int ind = 0;
    for (int i = 1; i < n; i++) {
        if (abs(nums[i] - nums[i-1]) <= 1) {
            if (nums[i] - nums[i-1] == 1) {
                if (small == nums[i-1]) {
                    big = nums[i];
                }
                else {
                    start = i;
                    small = nums[i];
                    big = -1;
                    continue;
                }
            }
            else if (nums[i] - nums[i-1] == -1) {
                if (big == -1) {
                    big = small;
                    small = nums[i];
                }
                else {
                    if (small != nums[i-1]) {
                        small = nums[i];
                    }
                    else {
                        start = i;
                        small = nums[i];
                        big = -1;
                        continue;
                    }
                }
            }

            if (len < i - start + 1) {
                len = i - start + 1;
                ind = start + 1;
            }
        }
        else {
            start = i;
            small = nums[i];
            big = -1;
        }
    }

    cout << len << " " << ind;
}
SubtaskSumTestVerdictTimeMemory
base35/55
1Accepted0/01ms316 KiB
2Wrong answer0/03ms316 KiB
3Accepted2/21ms508 KiB
4Accepted2/21ms500 KiB
5Wrong answer0/21ms316 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/31ms508 KiB
8Accepted2/21ms324 KiB
9Accepted3/31ms316 KiB
10Wrong answer0/34ms436 KiB
11Wrong answer0/33ms508 KiB
12Accepted3/33ms432 KiB
13Wrong answer0/332ms604 KiB
14Wrong answer0/317ms832 KiB
15Wrong answer0/325ms564 KiB
16Accepted3/332ms564 KiB
17Accepted3/332ms564 KiB
18Accepted3/332ms564 KiB
19Accepted3/332ms800 KiB
20Accepted3/332ms792 KiB
21Accepted3/317ms756 KiB
22Accepted3/326ms564 KiB