140442025-01-09 17:55:37Podlipnik07Inverziócpp17Wrong answer 9/5061ms2576 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> v(n+1);
    for (int i = 0; i < n; i++) {
        int temp; cin >> temp;
        v[temp] = i + 1;
    }
    int maxDiff = -1, maxEnd = -1;
    for (int i : v) {
        if (i == 0) continue;
        else if (i > maxEnd) {
            maxEnd = i;
        }
        else {
            maxDiff = max(maxDiff, maxEnd - i);
        }
    }
    if (maxDiff == -1) {
        cout << -1; return 0;
    }
    cout << maxEnd - maxDiff << " " << maxEnd;
}

//5
//4 3 5 1 2

// 4 5 2 1 3
SubtaskSumTestVerdictTimeMemory
base9/50
1Accepted0/01ms316 KiB
2Wrong answer0/06ms564 KiB
3Accepted1/11ms548 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/71ms316 KiB
6Accepted2/26ms564 KiB
7Wrong answer0/254ms2356 KiB
8Wrong answer0/259ms2356 KiB
9Accepted2/259ms2356 KiB
10Wrong answer0/257ms2572 KiB
11Wrong answer0/259ms2576 KiB
12Wrong answer0/259ms2300 KiB
13Wrong answer0/257ms2364 KiB
14Wrong answer0/256ms2356 KiB
15Wrong answer0/256ms2356 KiB
16Wrong answer0/261ms2356 KiB
17Wrong answer0/259ms2228 KiB
18Wrong answer0/254ms2356 KiB
19Wrong answer0/354ms2356 KiB
20Wrong answer0/357ms2356 KiB
21Wrong answer0/254ms2356 KiB
22Wrong answer0/259ms2356 KiB
23Wrong answer0/259ms2356 KiB
24Accepted2/254ms2356 KiB