33272023-02-25 19:42:44xxxVölgy (100 pont)cpp14Wrong answer 95/10037ms4688 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> t(n);

    int maxos = 0;
    int cnt = 0, cntmax= 0;
    for (int i = 0; i < n; i++) {
        cin >> t[i];
        if (t[i] >= maxos) {
            maxos = t[i];
            cntmax = max(cnt, cntmax);
            cnt = 1;
        }
        else {
            cnt++;
        }
    }

    maxos = 0;
    int maxi;
    if (cnt > cntmax) {
        for (int i = n-cnt+1; i < n; i++) {
            if (t[i] > maxos) {
                maxos = t[i];
                maxi = i;
            }
        }
    }

    if (maxi - (n-cnt) > cntmax) {
        cntmax = (maxi - (n-cnt));
    }

    if (cntmax < 2) {
        cout << -1 << endl;
        return 0;
    }
    else {
        cout << cntmax << endl;
    }
    return 0;
}

/*
6
4 4 1 1 2 1
*/
SubtaskSumTestVerdictTimeMemory
base95/100
1Accepted0/03ms1812 KiB
2Accepted0/03ms2056 KiB
3Accepted5/53ms2268 KiB
4Accepted5/52ms2332 KiB
5Accepted5/53ms2536 KiB
6Accepted5/53ms2784 KiB
7Accepted5/53ms2984 KiB
8Accepted5/53ms3200 KiB
9Accepted5/53ms3288 KiB
10Accepted5/53ms3364 KiB
11Accepted5/54ms3504 KiB
12Accepted5/54ms3884 KiB
13Accepted5/54ms3836 KiB
14Wrong answer0/56ms3824 KiB
15Accepted5/530ms4488 KiB
16Accepted5/535ms4380 KiB
17Accepted5/534ms4376 KiB
18Accepted5/534ms4604 KiB
19Accepted5/534ms4592 KiB
20Accepted5/537ms4592 KiB
21Accepted5/537ms4588 KiB
22Accepted5/537ms4688 KiB