237582026-01-28 19:05:55ProgramozoRokaInverziócpp17Accepted 50/5087ms4356 KiB
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	int maximum=-1,kezdo=0;
	cin >> n;
	vector<int> tomb(n);
	vector<int> seged(n);
	for (int i = 0; i < n; ++i) cin >> tomb[i];
	seged[n - 1] = tomb[n - 1];
	for (int i = n - 2; i >= 0; --i)
	{
		seged[i] = min(tomb[i], seged[i + 1]);
	}
	for (int i = 0; i < n; ++i)
	{
		auto it = lower_bound(seged.begin()+i+1, seged.end(), tomb[i]) - 1;
		int d = it - seged.begin() - i;
		if (d > maximum and d!=0)
		{
			maximum = d;
			kezdo = i + 1;
		}
	}
	if (maximum != -1) cout << kezdo << " " << kezdo + maximum;
	else cout << -1;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/08ms820 KiB
3Accepted1/11ms500 KiB
4Accepted2/21ms508 KiB
5Accepted7/71ms316 KiB
6Accepted2/28ms832 KiB
7Accepted2/282ms4148 KiB
8Accepted2/281ms4148 KiB
9Accepted2/279ms4164 KiB
10Accepted2/283ms4356 KiB
11Accepted2/286ms4152 KiB
12Accepted2/281ms4148 KiB
13Accepted2/282ms4148 KiB
14Accepted2/282ms4148 KiB
15Accepted2/286ms4148 KiB
16Accepted2/283ms4148 KiB
17Accepted2/287ms4340 KiB
18Accepted2/282ms4148 KiB
19Accepted3/386ms4348 KiB
20Accepted3/386ms4148 KiB
21Accepted2/286ms4148 KiB
22Accepted2/282ms4148 KiB
23Accepted2/285ms4148 KiB
24Accepted2/268ms4336 KiB