37612023-03-02 20:46:51rennVölgy (100 pont)cpp17Wrong answer 50/10037ms4940 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/03ms2092 KiB
2Accepted0/03ms2280 KiB
3Wrong answer0/52ms2320 KiB
4Accepted5/52ms2452 KiB
5Accepted5/52ms2668 KiB
6Accepted5/53ms2732 KiB
7Wrong answer0/52ms2872 KiB
8Accepted5/52ms2976 KiB
9Wrong answer0/53ms3104 KiB
10Accepted5/53ms3100 KiB
11Accepted5/54ms3128 KiB
12Wrong answer0/54ms3428 KiB
13Wrong answer0/54ms3460 KiB
14Accepted5/56ms3732 KiB
15Wrong answer0/534ms4700 KiB
16Wrong answer0/537ms4940 KiB
17Wrong answer0/534ms3652 KiB
18Accepted5/534ms3656 KiB
19Accepted5/534ms3656 KiB
20Accepted5/537ms3900 KiB
21Wrong answer0/537ms4144 KiB
22Wrong answer0/537ms4392 KiB