31402023-02-19 16:20:58horvathabelInverziócpp17Wrong answer 9/50207ms17960 KiB

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

int main() {
	int n; 
	cin>>n;
	vector<pair<int,int>> elso;
	vector<pair<int,int>> masodik;
	
	vector<int> szam;
	for (int i=1; i<=n;i++){
		int x; 
		cin>>x;
		szam.push_back(x);
		if (x<i){
			elso.push_back({i,x});
		}
		if (i<x) masodik.push_back({i,x});
	}
	sort(elso.begin(), elso.end(), greater<pair<int,int>>());
	sort(masodik.begin(), masodik.end());
	int i=0, j=0; 


	while (i<elso.size() && j<masodik.size()){
		if (elso[i].second<masodik[j].second){
			cout<<masodik[j].first<<" "<<elso[i].first;
			return 0; 
		}
		else{
			if (j+1==masodik.size()) i++;
			else{ 
				if (i+1==elso.size()) j++; 
			 	else if (abs(masodik[j].second-masodik[j+1].second)>abs(elso[i+1].second-elso[i+1].second)) i++;
					else j++; 
		}
	} 
	}
	cout<<-1;

}
SubtaskSumTestVerdictTimeMemory
base9/50
1Accepted0/03ms1808 KiB
2Wrong answer0/019ms3604 KiB
3Accepted1/13ms2268 KiB
4Accepted2/23ms2544 KiB
5Wrong answer0/73ms2664 KiB
6Wrong answer0/220ms4220 KiB
7Wrong answer0/2197ms13296 KiB
8Wrong answer0/2197ms17960 KiB
9Wrong answer0/2199ms15760 KiB
10Accepted2/2199ms15344 KiB
11Wrong answer0/2197ms15328 KiB
12Wrong answer0/2197ms15288 KiB
13Wrong answer0/2197ms15376 KiB
14Wrong answer0/2202ms15596 KiB
15Wrong answer0/2196ms14188 KiB
16Wrong answer0/2199ms15772 KiB
17Wrong answer0/2197ms15732 KiB
18Wrong answer0/2197ms15872 KiB
19Wrong answer0/3197ms14212 KiB
20Wrong answer0/3196ms14208 KiB
21Wrong answer0/2207ms14272 KiB
22Wrong answer0/2200ms15784 KiB
23Accepted2/2200ms16032 KiB
24Accepted2/2177ms8340 KiB