251632026-02-18 10:07:16ProgramozoRokaLegmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/3523ms1268 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
base35/35
1Accepted0/01ms508 KiB
2Accepted0/023ms1260 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms500 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted1/11ms316 KiB
9Accepted1/11ms316 KiB
10Accepted1/11ms316 KiB
11Accepted1/12ms508 KiB
12Accepted2/28ms564 KiB
13Accepted2/28ms564 KiB
14Accepted2/28ms812 KiB
15Accepted2/26ms564 KiB
16Accepted2/29ms820 KiB
17Accepted2/217ms988 KiB
18Accepted2/217ms896 KiB
19Accepted2/219ms1076 KiB
20Accepted2/219ms1076 KiB
21Accepted2/223ms1076 KiB
22Accepted2/223ms1268 KiB
23Accepted2/213ms1080 KiB
24Accepted2/213ms1104 KiB