85342024-01-21 15:52:57gergomiszoriLegmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/35123ms28124 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pll pair<long, long>
#define endl "\n"
#define first fs
#define second sc
#define vll vector<ll>

void solve()
{
	ll n;
	cin >> n;
	vll a(n);
	map<ll, vector<ll>> m;
	ll ans[2] = {-1, 0};
	for(ll i = 0; i < n; i++)
	{
		cin >> a[i];
		m[a[i]].push_back(i);
	}
	sort(a.begin(), a.end());
	ll sm = 0;
	for(ll i = 0; i < n; i++)
	{
		if(i != 0 && a[i] == a[i-1]) continue;
		if(sm - m[a[i]][0] > ans[1] - ans[0])
		{
			ans[1] = sm;
			ans[0] = m[a[i]][0];
		}
		if(m[a[i]][m[a[i]].size()-1] > sm) sm = m[a[i]][m[a[i]].size()-1];
	}
	if(ans[0] == -1)
	{
		cout << -1 << endl;
		return;
	}
	cout << ans[0]+1 << " " << ans[1]+1;
}

int main() 
{
	cin.tie(NULL); cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	ll t = 1;
	//cin >> t;
	while(t--) solve();
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1828 KiB
2Accepted0/081ms18448 KiB
3Accepted1/13ms2920 KiB
4Accepted1/13ms3140 KiB
5Accepted1/13ms3348 KiB
6Accepted1/13ms3720 KiB
7Accepted1/13ms3720 KiB
8Accepted1/13ms3928 KiB
9Accepted1/14ms4344 KiB
10Accepted1/14ms4552 KiB
11Accepted1/16ms5108 KiB
12Accepted2/228ms10344 KiB
13Accepted2/232ms11304 KiB
14Accepted2/232ms11920 KiB
15Accepted2/220ms8820 KiB
16Accepted2/234ms12068 KiB
17Accepted2/257ms15252 KiB
18Accepted2/264ms16940 KiB
19Accepted2/271ms18520 KiB
20Accepted2/275ms18624 KiB
21Accepted2/283ms20084 KiB
22Accepted2/283ms20212 KiB
23Accepted2/2120ms27620 KiB
24Accepted2/2123ms28124 KiB