3757 2023. 03. 02 20:22:22 renn Völgy (100 pont) cpp17 Wrong answer 20/100 14ms 4756 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;
}
Subtask Sum Test Verdict Time Memory
base 20/100
1 Accepted 0/0 3ms 1832 KiB
2 Wrong answer 0/0 3ms 2056 KiB
3 Wrong answer 0/5 3ms 2260 KiB
4 Wrong answer 0/5 3ms 2460 KiB
5 Accepted 5/5 3ms 2672 KiB
6 Wrong answer 0/5 2ms 2752 KiB
7 Wrong answer 0/5 2ms 2884 KiB
8 Wrong answer 0/5 3ms 3104 KiB
9 Wrong answer 0/5 2ms 3212 KiB
10 Wrong answer 0/5 3ms 3208 KiB
11 Wrong answer 0/5 3ms 3592 KiB
12 Wrong answer 0/5 3ms 3476 KiB
13 Wrong answer 0/5 4ms 3736 KiB
14 Wrong answer 0/5 4ms 3684 KiB
15 Wrong answer 0/5 13ms 4756 KiB
16 Wrong answer 0/5 14ms 4636 KiB
17 Wrong answer 0/5 12ms 3508 KiB
18 Accepted 5/5 12ms 3508 KiB
19 Accepted 5/5 12ms 3508 KiB
20 Accepted 5/5 13ms 3508 KiB
21 Wrong answer 0/5 13ms 3732 KiB
22 Wrong answer 0/5 13ms 4088 KiB