37572023-03-02 20:22:22rennVölgy (100 pont)cpp17Wrong answer 20/10014ms4756 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;

    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;
    queue<pii*> jocsucsok;
    jocsucsok.push(&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))
            jocsucsok.push(&csucsok[i]);
    }

    jocsucsok.push(&csucsok[csucsok.size()-1]);

    pii* p = jocsucsok.front();
    jocsucsok.pop();

    while(!jocsucsok.empty())
    {
        maxl = max(jocsucsok.front()->second-p->second, maxl);
        p = jocsucsok.front();
        jocsucsok.pop();
    }

    cout << maxl << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base20/100
1Accepted0/03ms1832 KiB
2Wrong answer0/03ms2056 KiB
3Wrong answer0/53ms2260 KiB
4Wrong answer0/53ms2460 KiB
5Accepted5/53ms2672 KiB
6Wrong answer0/52ms2752 KiB
7Wrong answer0/52ms2884 KiB
8Wrong answer0/53ms3104 KiB
9Wrong answer0/52ms3212 KiB
10Wrong answer0/53ms3208 KiB
11Wrong answer0/53ms3592 KiB
12Wrong answer0/53ms3476 KiB
13Wrong answer0/54ms3736 KiB
14Wrong answer0/54ms3684 KiB
15Wrong answer0/513ms4756 KiB
16Wrong answer0/514ms4636 KiB
17Wrong answer0/512ms3508 KiB
18Accepted5/512ms3508 KiB
19Accepted5/512ms3508 KiB
20Accepted5/513ms3508 KiB
21Wrong answer0/513ms3732 KiB
22Wrong answer0/513ms4088 KiB