54532023-06-21 11:03:14levaip0531Legmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/3552ms6040 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/03ms1812 KiB
2Accepted0/052ms3408 KiB
3Accepted1/13ms2232 KiB
4Accepted1/13ms2444 KiB
5Accepted1/13ms2656 KiB
6Accepted1/13ms2868 KiB
7Accepted1/13ms2980 KiB
8Accepted1/13ms3088 KiB
9Accepted1/13ms3336 KiB
10Accepted1/14ms3432 KiB
11Accepted1/14ms3428 KiB
12Accepted2/219ms3916 KiB
13Accepted2/223ms4132 KiB
14Accepted2/224ms4264 KiB
15Accepted2/216ms4160 KiB
16Accepted2/225ms4576 KiB
17Accepted2/237ms4992 KiB
18Accepted2/243ms5340 KiB
19Accepted2/246ms5704 KiB
20Accepted2/250ms5668 KiB
21Accepted2/252ms5808 KiB
22Accepted2/252ms5892 KiB
23Accepted2/239ms6040 KiB
24Accepted2/239ms5892 KiB