32172023-02-22 18:00:19horvathabelInverziócpp17Wrong answer 47/50184ms11776 KiB
// Source: https://usaco.guide/general/io

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	vector<int> keres(n+1); 
	for (int i=0; i<n;i++){
		int c;
		cin>>c;
		keres[c]=i+1;
	
	}
	vector<int> dp(n+1);
	dp[1]=-1;
	int ans=-1;
	pair<int, int> ans2; 
	pair<int,int> lj={1,keres[1]};
	for (int i=2; i<=n;i++){
		if (lj.second>keres[i]){
			dp[i]=lj.second;
		}
		else{
			dp[i]=-1;
			lj.second=keres[i];
			lj.first=i;
		}
			if (dp[i]!=-1){
				if (ans<dp[i]-keres[i]){
					ans=dp[i]-keres[i];
					ans2=make_pair(keres[i], dp[i]);
				}	
			}

	}
	
cout<<ans2.first<<" "<<ans2.second; 
}
SubtaskSumTestVerdictTimeMemory
base47/50
1Accepted0/03ms1812 KiB
2Accepted0/017ms2760 KiB
3Wrong answer0/13ms2248 KiB
4Accepted2/23ms2484 KiB
5Accepted7/73ms2560 KiB
6Accepted2/218ms3464 KiB
7Accepted2/2173ms10440 KiB
8Accepted2/2178ms10440 KiB
9Accepted2/2180ms10440 KiB
10Accepted2/2174ms10700 KiB
11Accepted2/2174ms10908 KiB
12Accepted2/2174ms10992 KiB
13Accepted2/2178ms11356 KiB
14Accepted2/2175ms11316 KiB
15Accepted2/2172ms11568 KiB
16Accepted2/2184ms11644 KiB
17Accepted2/2177ms11752 KiB
18Accepted2/2174ms11776 KiB
19Accepted3/3172ms11772 KiB
20Accepted3/3172ms11776 KiB
21Accepted2/2172ms11776 KiB
22Accepted2/2175ms11776 KiB
23Accepted2/2175ms11772 KiB
24Wrong answer0/2172ms11776 KiB