251662026-02-18 10:19:33ProgramozoRokaLegmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/3514ms1212 KiB
#include <iostream>
#include<vector>
#include <algorithm>
using namespace std;

#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif

inline int rin() {
	int x = 0;
	int f = 1;
	char ch = getchar_unlocked();

	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar_unlocked();
	}

	while (ch >= '0' && ch <= '9') {
		x = (x << 3) + (x << 1) + (ch - '0');
		ch = getchar_unlocked();
	}

	return x * f;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	int maximum = -1, kezdo = 0;

	n=rin();
	vector<int> tomb(n);
	vector<int> seged(n);
	for (int i = 0; i < n; ++i) tomb[i]=rin();
	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/01ms500 KiB
2Accepted0/014ms1076 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms316 KiB
6Accepted1/11ms500 KiB
7Accepted1/11ms316 KiB
8Accepted1/12ms316 KiB
9Accepted1/12ms500 KiB
10Accepted1/11ms616 KiB
11Accepted1/12ms316 KiB
12Accepted2/24ms756 KiB
13Accepted2/24ms792 KiB
14Accepted2/24ms812 KiB
15Accepted2/23ms564 KiB
16Accepted2/24ms568 KiB
17Accepted2/29ms988 KiB
18Accepted2/212ms820 KiB
19Accepted2/213ms1120 KiB
20Accepted2/213ms1144 KiB
21Accepted2/214ms1212 KiB
22Accepted2/214ms1200 KiB
23Accepted2/24ms1100 KiB
24Accepted2/24ms1076 KiB