37592023-03-02 20:42:40rennVölgy (100 pont)cpp17Wrong answer 50/10014ms4764 KiB
#include <bits/stdc++.h>
using namespace std;

#define GOTTAGOFAST cin.tie(0); ios::sync_with_stdio(0);
typedef pair<int,int> pii;

int main() {

    GOTTAGOFAST

    int n;
    cin >> n;

    int prev = -1, curr, next;
    cin >> curr;

    vector<pii> csucsok, kovcsucsok;

    for(int i = 1; i < n; i++)
    {
        cin >> next;
        if((curr > prev && curr > next) || (curr == prev && curr > next) || (curr > prev && curr == next))
        {
            csucsok.push_back({curr, i});
        }
        prev = curr;
        curr = next;
    }
    next = -1;
    if((curr > prev && curr > next) || (curr == prev && curr > next) || (curr > prev && curr == next))
    {
        csucsok.push_back({curr, n});
    }

    if(csucsok.size() < 2)
    {
        cout << "0\n";
        return 0;
    }

    if(csucsok.size() == 2)
    {
        cout << csucsok[1].second-csucsok[0].second << "\n";
        return 0;
    }

    int maxl = -1;
    while(1) {
        kovcsucsok.push_back(csucsok[0]);

        for (int i = 1, j = csucsok.size() - 1; i < j; i++) {
            if (!(csucsok[i].first < csucsok[i - 1].first && csucsok[i].first < csucsok[i + 1].first)) {
                kovcsucsok.push_back(csucsok[i]);
            }
        }

        kovcsucsok.push_back(csucsok[csucsok.size() - 1]);
        if(csucsok.size() == kovcsucsok.size())
            break;

        csucsok = kovcsucsok;
        kovcsucsok.clear();
    }

    for(int i = 1; i < csucsok.size(); i++)
    {
        maxl = max(csucsok[i].second-csucsok[i-1].second, maxl);
    }

    cout << maxl << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/100
1Accepted0/03ms1824 KiB
2Accepted0/03ms2068 KiB
3Wrong answer0/52ms2268 KiB
4Accepted5/52ms2484 KiB
5Accepted5/53ms2672 KiB
6Accepted5/52ms2884 KiB
7Wrong answer0/52ms2980 KiB
8Accepted5/52ms3196 KiB
9Wrong answer0/53ms3416 KiB
10Accepted5/52ms3408 KiB
11Accepted5/53ms3636 KiB
12Wrong answer0/53ms3724 KiB
13Wrong answer0/54ms3632 KiB
14Accepted5/54ms3800 KiB
15Wrong answer0/514ms4756 KiB
16Wrong answer0/514ms4764 KiB
17Wrong answer0/512ms3496 KiB
18Accepted5/512ms3608 KiB
19Accepted5/512ms3836 KiB
20Accepted5/513ms3920 KiB
21Wrong answer0/513ms4152 KiB
22Wrong answer0/513ms4136 KiB