54512023-06-12 08:02:39HoraLegmesszebbi rossz sorrendű (35 pont)cpp11Accepted 35/3550ms5556 KiB
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> szam(n);
	vector<int> mini(n, 100001);
	cin >> szam[0];
	for (int i = 1; i < n; i++) {
		cin >> szam[i];
	}
	mini[n - 1] = szam[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		mini[i] = min(szam[i], mini[i + 1]);
	}
	int maxi = 0;
	pair<int, int> maxii;
	for (int i = 0; i < n; i++) {
		int lo = i, hi = n - 1;
		while (lo < hi) {
			int mid = lo + (hi - lo + 1) / 2;
			if (mini[mid] >= szam[i]) hi = mid - 1;
			else lo = mid;
		}
		if (lo - i > maxi && szam[i] > szam[lo]) {
			maxi = lo - i;
			maxii.first = i + 1;
			maxii.second = lo + 1;
		}
	}
	if (maxi != 0) cout << maxii.first << " " << maxii.second;
	else cout << -1;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1948 KiB
2Accepted0/050ms3536 KiB
3Accepted1/13ms2260 KiB
4Accepted1/13ms2420 KiB
5Accepted1/13ms2620 KiB
6Accepted1/12ms2712 KiB
7Accepted1/13ms2708 KiB
8Accepted1/13ms2712 KiB
9Accepted1/13ms3000 KiB
10Accepted1/14ms3128 KiB
11Accepted1/14ms3100 KiB
12Accepted2/218ms3716 KiB
13Accepted2/221ms3856 KiB
14Accepted2/223ms4132 KiB
15Accepted2/214ms3780 KiB
16Accepted2/224ms4140 KiB
17Accepted2/235ms4268 KiB
18Accepted2/239ms4848 KiB
19Accepted2/243ms4852 KiB
20Accepted2/245ms5112 KiB
21Accepted2/248ms5344 KiB
22Accepted2/250ms5252 KiB
23Accepted2/237ms5468 KiB
24Accepted2/237ms5556 KiB