70762023-12-29 18:56:38MagyarKendeSZLGVölgy (100 pont)cpp17Time limit exceeded 75/100300ms4668 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;
using ll = long long;
using point = array<int, 2>;

int main() {
    speed;

    int N;
    cin >> N;


    vector<int> T(N);
    cinv(T);

    if (N < 3) {
        cout << -1;
        exit(0);
    }
    
    int max_l = 1;

    for (int i = 0; i < N; i++) {
        int max_h = 0;
        for (int j = i + 1; j < N - 1; j++) {
            if (T[i] <= T[j]) break;
            max_h = max(max_h, T[j]);
            if (max_h < T[j + 1]) {
                max_l = max(max_l, j + 1 - i);
            }
        }
    }

    cout << (max_l == 1 ? -1 : max_l);
}
SubtaskSumTestVerdictTimeMemory
base75/100
1Accepted0/03ms1864 KiB
2Accepted0/03ms2024 KiB
3Accepted5/53ms2232 KiB
4Accepted5/53ms2312 KiB
5Accepted5/53ms2316 KiB
6Accepted5/53ms2444 KiB
7Accepted5/53ms2652 KiB
8Accepted5/53ms2740 KiB
9Accepted5/54ms3120 KiB
10Accepted5/53ms2920 KiB
11Accepted5/53ms2976 KiB
12Accepted5/54ms3260 KiB
13Accepted5/54ms3472 KiB
14Accepted5/54ms3560 KiB
15Accepted5/514ms4176 KiB
16Accepted5/516ms4376 KiB
17Time limit exceeded0/5300ms3480 KiB
18Accepted5/514ms4668 KiB
19Time limit exceeded0/5300ms3816 KiB
20Time limit exceeded0/5257ms3892 KiB
21Time limit exceeded0/5261ms3892 KiB
22Time limit exceeded0/5266ms3976 KiB