209182026-01-11 13:01:42hunzombiInverziócpp17Wrong answer 6/50182ms6200 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> arr(n + 1, 0);
    vector<int> prefMax(n + 1, 0);
    for (int i=1; i <= n; i++) {
        cin >> arr[i];
        prefMax[i] = max(prefMax[i - 1], arr[i]);
    }
    vector<int> suffMin(n + 2, 1e8);
    for (int i=n; i > 0; i--) {
        suffMin[i] = min(suffMin[i + 1], arr[i]);
    }

    int low = 0, high = n;
    int best_dist = -1;
    int best_i = -1, best_j = -1;
    while (low < high) {
        if (prefMax[low] > suffMin[high]) {
            if (high - low > best_dist) {
                best_i = low;
                best_j = high;
            }
            high++;
        } else {
            low++;
        }
    }

    cout << best_i << ' ' << best_j;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/01ms508 KiB
2Wrong answer0/017ms820 KiB
3Wrong answer0/11ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/71ms316 KiB
6Accepted2/217ms800 KiB
7Wrong answer0/2180ms6196 KiB
8Wrong answer0/2182ms6116 KiB
9Accepted2/2177ms6120 KiB
10Wrong answer0/2179ms6188 KiB
11Wrong answer0/2178ms6124 KiB
12Wrong answer0/2174ms5940 KiB
13Wrong answer0/2179ms6120 KiB
14Wrong answer0/2178ms6120 KiB
15Wrong answer0/2178ms6120 KiB
16Wrong answer0/2179ms6196 KiB
17Wrong answer0/2178ms6124 KiB
18Wrong answer0/2179ms6120 KiB
19Wrong answer0/3179ms6124 KiB
20Wrong answer0/3178ms6200 KiB
21Wrong answer0/2179ms6196 KiB
22Wrong answer0/2178ms6116 KiB
23Wrong answer0/2178ms6120 KiB
24Wrong answer0/2179ms6196 KiB