131382025-01-06 18:12:34HolloGInverziócpp17Wrong answer 9/5068ms4368 KiB
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

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

    int n; cin >> n;
	vector<int> sor(n);
	vector<int> indexek(n + 1);
	for (int i = 0; i < n; i++)
	{
		cin >> sor[i];
		indexek[sor[i]] = i + 1;
	}
	int maxd = 0, maxi = 0, maxj = 0;
	for (int i = 1; i < n+1; i++)
	{
		maxj = max(maxj, indexek[i - 1]);
		if (indexek[i] < maxj)
		{
			int prev = maxd;
			maxd = max(maxd, maxj - indexek[i]);
			if (maxd != prev) maxi = indexek[i];
		}
	}
	if (maxd == 0) cout << -1;
	else cout << maxi << " " << maxj;
}

SubtaskSumTestVerdictTimeMemory
base9/50
1Accepted0/01ms316 KiB
2Wrong answer0/07ms1012 KiB
3Accepted1/11ms316 KiB
4Accepted2/21ms508 KiB
5Wrong answer0/71ms316 KiB
6Accepted2/27ms568 KiB
7Wrong answer0/261ms4356 KiB
8Wrong answer0/268ms4232 KiB
9Accepted2/264ms4356 KiB
10Wrong answer0/265ms4148 KiB
11Wrong answer0/264ms4352 KiB
12Wrong answer0/265ms4148 KiB
13Wrong answer0/267ms4148 KiB
14Wrong answer0/263ms4148 KiB
15Wrong answer0/261ms4348 KiB
16Wrong answer0/264ms4348 KiB
17Wrong answer0/265ms4148 KiB
18Wrong answer0/264ms4148 KiB
19Wrong answer0/364ms4148 KiB
20Wrong answer0/361ms4148 KiB
21Wrong answer0/261ms4348 KiB
22Wrong answer0/264ms4148 KiB
23Wrong answer0/265ms4368 KiB
24Accepted2/261ms4356 KiB