69952023-12-24 16:03:14MagyarKendeSZLGInverziócpp17Accepted 50/5070ms7688 KiB
#include <iostream>
#include <vector>
#include <array>
using namespace std;
#define speed cin.tie(0); ios::sync_with_stdio(false)

using point = array<int, 2>;

int main() {
    speed;

    int N;
    cin >> N;
    vector<int> v(N + 1);

    for (int i = 1, a; i <= N; i++) {
        cin >> a;
        v[a] = i;
    }

    int min_i = v[N];
    point p{0, 0};

    for (int i = N - 1; i > 0; i--) {
        if (v[i] < min_i) {
            min_i = v[i];
        } else {
            int diff = v[i] - min_i;
            if ((p[1] - p[0]) < diff) {
                p = { min_i, v[i] };
            }
        }
    }

    if (p[1] - p[0]) cout << p[0] << ' ' << p[1];
    else cout << -1;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms2104 KiB
2Accepted0/08ms2608 KiB
3Accepted1/13ms2432 KiB
4Accepted2/23ms2576 KiB
5Accepted7/73ms2812 KiB
6Accepted2/28ms3068 KiB
7Accepted2/268ms6712 KiB
8Accepted2/268ms6796 KiB
9Accepted2/268ms6836 KiB
10Accepted2/267ms6876 KiB
11Accepted2/268ms6840 KiB
12Accepted2/264ms6796 KiB
13Accepted2/265ms6800 KiB
14Accepted2/265ms6796 KiB
15Accepted2/264ms6800 KiB
16Accepted2/268ms6796 KiB
17Accepted2/265ms7052 KiB
18Accepted2/265ms7012 KiB
19Accepted3/367ms7056 KiB
20Accepted3/364ms7012 KiB
21Accepted2/267ms7264 KiB
22Accepted2/268ms7564 KiB
23Accepted2/270ms7688 KiB
24Accepted2/265ms7648 KiB