48792023-04-05 21:28:34SleepyOverlordLegmesszebbi rossz sorrendű (35 pont)cpp17Elfogadva 35/3546ms7288 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

int n;
VI a, b;

int main()
{
	cin >> n;
	a.RS(n + 1);
	FOR(i, 1, n) cin >> a[i];
	++n;
	a.PB(100001);
	b.PB(n);
	FORD(i, n - 1, 1)
		if (a[i] < a[b.back()]) b.PB(i);
	b.PB(0);

	int left = -1, right = -1;
	FOR(i, 1, n)
	{
		int l = 0, r = b.SZ - 1;
		while (r - l > 1)
		{
			int m = (r + l) / 2;
			if (a[i] > a[b[m]]) r = m;
			else l = m;
		}
		if (i > b[r]) continue;
		if (left == -1 || b[r] - i > right - left)
		{
			left = i;
			right = b[r];
		}
	}

	if (left == -1) cout << -1;
	else cout << left << " " << right;
	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base35/35
1Elfogadva0/03ms1876 KiB
2Elfogadva0/045ms3468 KiB
3Elfogadva1/13ms2444 KiB
4Elfogadva1/13ms2684 KiB
5Elfogadva1/12ms2868 KiB
6Elfogadva1/13ms2852 KiB
7Elfogadva1/13ms3060 KiB
8Elfogadva1/13ms3300 KiB
9Elfogadva1/13ms3288 KiB
10Elfogadva1/14ms3304 KiB
11Elfogadva1/14ms3444 KiB
12Elfogadva2/220ms3880 KiB
13Elfogadva2/223ms4196 KiB
14Elfogadva2/224ms4532 KiB
15Elfogadva2/216ms4340 KiB
16Elfogadva2/225ms4832 KiB
17Elfogadva2/230ms5388 KiB
18Elfogadva2/235ms5712 KiB
19Elfogadva2/239ms5956 KiB
20Elfogadva2/241ms5996 KiB
21Elfogadva2/245ms6124 KiB
22Elfogadva2/245ms6336 KiB
23Elfogadva2/246ms7288 KiB
24Elfogadva2/246ms7212 KiB