142002025-01-10 08:59:10RRoliInverziócpp17Accepted 50/50187ms4332 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> v(n), ind(n+1);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
		ind[v[i]] = i+1;
	}

	int ln = ind[1], maxtav = -1, hely = -1;
	for(int i = 2; i <= n; i++) {
		if(ind[i] < ln) {
			if(ln - ind[i] > maxtav) {
				maxtav = ln - ind[i];
				hely = ind[i];
			}
		} else ln = ind[i];
	}
	if(maxtav == -1) cout << -1;
	else cout << hely << ' ' << hely + maxtav;

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/017ms564 KiB
3Accepted1/11ms316 KiB
4Accepted2/21ms316 KiB
5Accepted7/71ms316 KiB
6Accepted2/217ms808 KiB
7Accepted2/2174ms4332 KiB
8Accepted2/2187ms4332 KiB
9Accepted2/2186ms4324 KiB
10Accepted2/2179ms4152 KiB
11Accepted2/2181ms4148 KiB
12Accepted2/2180ms4148 KiB
13Accepted2/2180ms4332 KiB
14Accepted2/2179ms4332 KiB
15Accepted2/2174ms4148 KiB
16Accepted2/2184ms4148 KiB
17Accepted2/2180ms4332 KiB
18Accepted2/2179ms4328 KiB
19Accepted3/3175ms4148 KiB
20Accepted3/3174ms4148 KiB
21Accepted2/2175ms4148 KiB
22Accepted2/2179ms4148 KiB
23Accepted2/2182ms4148 KiB
24Accepted2/2174ms4328 KiB