158452025-03-04 22:23:05rennVölgy (100 pont)cpp17Wrong answer 75/10013ms772 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin >> n;

    int mag[n];
    for(int i = 0; i < n; i++)
        cin >> mag[i];
    
    int h = 1;
    int p = 0, k = n-1;
    for(int i = 1; i < n; i++)
    {
        if(mag[i] >= mag[p])
        {
            if(i-p > h)
                h = i-p;
            
            p = i;
        }

        if(mag[n-i-1] >= mag[k])
        {
            if(k-i-1 > h)
            {
                h = k-(n-i-1);
            }
            
            k = n-i-1;
        }
    }

    cout << (h == 1 ? -1 : h) << endl;
}
SubtaskSumTestVerdictTimeMemory
base75/100
1Accepted0/01ms316 KiB
2Wrong answer0/01ms508 KiB
3Accepted5/51ms316 KiB
4Accepted5/51ms316 KiB
5Wrong answer0/51ms316 KiB
6Wrong answer0/51ms316 KiB
7Accepted5/51ms316 KiB
8Accepted5/51ms316 KiB
9Accepted5/51ms508 KiB
10Accepted5/51ms316 KiB
11Accepted5/51ms316 KiB
12Wrong answer0/52ms316 KiB
13Accepted5/52ms316 KiB
14Wrong answer0/52ms452 KiB
15Wrong answer0/510ms708 KiB
16Accepted5/512ms656 KiB
17Accepted5/512ms564 KiB
18Accepted5/512ms644 KiB
19Accepted5/512ms772 KiB
20Accepted5/513ms632 KiB
21Accepted5/513ms564 KiB
22Accepted5/513ms564 KiB