50712023-04-14 11:50:27czitaLegmesszebbi rossz sorrendű (35 pont)cpp17Wrong answer 3/3557ms7432 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> E,R,K;
int logker(int a)
{
	int e = 0, v = R.size() - 1,fele;
	bool talalt = false;
	while (!talalt&&e<=v)
	{
		fele = (e + v) / 2;
		if (a==R[fele])
		{
			return fele;
		}
		else if (a > R[fele])
		{
			e = fele + 1;
		}
		else
		{
			v = fele - 1;
		}
	}
	return -1;
}
/*
10
7 2 4 17 6 5 10 10 18 19
*/
int main()
{
	int n;
	cin >> n;
	
	int a;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a;
		E.push_back(a);
		R.push_back(a);
	}
	sort(R.begin(),R.end());
	for (size_t i = 0; i < n; i++)
	{
		K.push_back(i - logker(E[i]));
	}
	int minn = 0,maxx=0;
	for (size_t i = 0; i < n; i++)
	{
		if (K[i]<K[minn])
		{
			minn = i;
		}
		if (K[i] > K[maxx])
		{
			maxx = i;
		}
	}
	if (K[minn]>0&&K[maxx]>0)
	{
		cout << -1 << endl;
	}
	else
	cout << abs(minn)+1 << " " << abs(maxx)+1 << endl;
}

SubtaskSumTestVerdictTimeMemory
base3/35
1Accepted0/03ms1744 KiB
2Wrong answer0/057ms4968 KiB
3Wrong answer0/13ms2208 KiB
4Wrong answer0/12ms2204 KiB
5Wrong answer0/13ms2332 KiB
6Accepted1/12ms2420 KiB
7Wrong answer0/13ms2548 KiB
8Wrong answer0/13ms2648 KiB
9Wrong answer0/13ms2888 KiB
10Wrong answer0/14ms2912 KiB
11Wrong answer0/14ms3164 KiB
12Wrong answer0/221ms4736 KiB
13Wrong answer0/224ms4784 KiB
14Wrong answer0/226ms5032 KiB
15Wrong answer0/217ms4660 KiB
16Wrong answer0/227ms5316 KiB
17Wrong answer0/241ms6352 KiB
18Wrong answer0/246ms6616 KiB
19Wrong answer0/252ms6996 KiB
20Wrong answer0/252ms6996 KiB
21Wrong answer0/257ms6960 KiB
22Wrong answer0/257ms7088 KiB
23Accepted2/245ms7212 KiB
24Wrong answer0/246ms7432 KiB