85062024-01-19 16:56:57zeytonxLegmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/35119ms34248 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/03ms1832 KiB
2Accepted0/082ms18444 KiB
3Accepted1/13ms3028 KiB
4Accepted1/13ms3244 KiB
5Accepted1/13ms3460 KiB
6Accepted1/13ms3548 KiB
7Accepted1/13ms3444 KiB
8Accepted1/13ms3800 KiB
9Accepted1/14ms4312 KiB
10Accepted1/14ms4676 KiB
11Accepted1/16ms5244 KiB
12Accepted2/228ms10700 KiB
13Accepted2/230ms12076 KiB
14Accepted2/232ms12832 KiB
15Accepted2/220ms10012 KiB
16Accepted2/234ms13420 KiB
17Accepted2/256ms17124 KiB
18Accepted2/264ms19296 KiB
19Accepted2/271ms21252 KiB
20Accepted2/274ms22220 KiB
21Accepted2/281ms24364 KiB
22Accepted2/279ms25156 KiB
23Accepted2/2118ms33096 KiB
24Accepted2/2119ms34248 KiB