54462023-06-06 21:46:44SleepyOverlordLegmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/3539ms6984 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

template <class T> ostream& operator <<(ostream & os, const vector<T> &vec)
{
	for (int i = 0; i < vec.size() - 1; ++i) os << vec[i] << ' ';
	return os << vec[vec.size() - 1];
}

template <class T1, class T2> ostream& operator <<(ostream & os, const pair<T1, T2> &p)
{
	return os << p.X << " " << p.Y;
}

template <typename T>
void pr(T var1)
{
	cout << var1 << '\n';
}
template <typename T, typename... Types>
void pr(T var1, Types... var2)
{
	cout << var1;
	pr(var2...);
}

void in(int &n, VI &a) //array of ints
{
	cin >> n;
	a.CL, a.RS(n + 1);
	FOR(i, 1, n) cin >> a[i];
}

int n;
VI a;
deque <PII> dq;

int main()
{
	#ifdef AT_HOME
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
	#endif

	in(n, a);
	FOR(i, 1, n)
	{
		while (!dq.empty() and a[i] <= dq.back().X) dq.pop_back();
		dq.push_back({a[i], i});
	}
	int sol1 = -1, sol2 = -1;
	FOR(i, 1, n)
	{
		while (!dq.empty() and a[i] > dq.front().X)
		{
			if (i < dq.front().Y and 
			(sol1 == -1 or sol2 - sol1 < dq.front().Y - i))
			{
				sol1 = i;
				sol2 = dq.front().Y;
			}
			dq.pop_front();
		}
	}

	if (sol1 == -1) pr(-1);
	else pr(sol1, " ", sol2);

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1688 KiB
2Accepted0/039ms2560 KiB
3Accepted1/13ms2076 KiB
4Accepted1/13ms2324 KiB
5Accepted1/13ms2532 KiB
6Accepted1/13ms2856 KiB
7Accepted1/13ms2952 KiB
8Accepted1/13ms2908 KiB
9Accepted1/13ms3032 KiB
10Accepted1/14ms3256 KiB
11Accepted1/14ms3476 KiB
12Accepted2/217ms3892 KiB
13Accepted2/218ms4084 KiB
14Accepted2/219ms4040 KiB
15Accepted2/213ms4136 KiB
16Accepted2/220ms4396 KiB
17Accepted2/228ms4672 KiB
18Accepted2/232ms4740 KiB
19Accepted2/235ms5044 KiB
20Accepted2/235ms5244 KiB
21Accepted2/239ms5476 KiB
22Accepted2/239ms5476 KiB
23Accepted2/235ms6984 KiB
24Accepted2/235ms6928 KiB