80832024-01-12 12:27:22GhostSíkság (55)cpp17Wrong answer 37/5535ms4432 KiB
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;

    pair<int, int> out = {0,0}, minmax, length;
    bool init = false, started = false;
    int hight;
    for (int i = 0; i < n; i++) {
        cin >> hight;
        if (!started) {
            length = { 1, i + 1 };
            minmax.first = hight;
            started = true;
        }
        else if (!init && (minmax.first + 1 == hight || minmax.first - 1 == hight ) ) {
            length.first++;
            minmax.second = hight;
            init = true;
        }
        else if (minmax.first == hight || minmax.second == hight) {
            length.first++;
        }
        else {
            init = false;
            minmax.first = hight;
            started = true;
            if (out.first < length.first) {
                out = length;
            }
            length = { 1, i + 1 };
        }
    }
    if (out.first < length.first) {
        out = length;
    }
    cout << out.first << " " << out.second;
}
SubtaskSumTestVerdictTimeMemory
base37/55
1Accepted0/03ms1872 KiB
2Wrong answer0/04ms2272 KiB
3Accepted2/23ms2344 KiB
4Accepted2/23ms2500 KiB
5Accepted2/23ms2856 KiB
6Accepted2/23ms2828 KiB
7Wrong answer0/33ms2800 KiB
8Accepted2/23ms3000 KiB
9Accepted3/33ms3088 KiB
10Wrong answer0/34ms3212 KiB
11Wrong answer0/34ms3576 KiB
12Accepted3/34ms3520 KiB
13Wrong answer0/334ms3516 KiB
14Wrong answer0/319ms3796 KiB
15Wrong answer0/327ms3664 KiB
16Accepted3/334ms3776 KiB
17Accepted3/335ms4028 KiB
18Accepted3/335ms3916 KiB
19Accepted3/335ms4320 KiB
20Accepted3/335ms4204 KiB
21Accepted3/318ms4432 KiB
22Accepted3/328ms4360 KiB