131162025-01-06 16:50:53ubormaciInverziócpp17Elfogadva 50/5086ms8436 KiB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <array>
#include <string>
#include <cstdio>
#include <iterator>
#include <unordered_set>
#include <cstdint>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <fstream>
using namespace std;

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

/*

notes:

int64_t
stoi(string s) -> string to int
to_string() -> int (or else) to string

vector declaration:
vector<ll> v(n, 0)
vector<vector<ll>> v(n, vector<ll>(n, 0));

{if statement} ? {truth value} : {false value}

set lower bound/upper bound:
 	// . . . m1 . . . d . . . . m2
    auto m1_it = b.lower_bound(d);
    advance(m1_it, -1);
    m1 = *m1_it;
	m2 = *b.upper_bound(d);

#ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif

constexpr auto lcm(auto x, auto... xs)
{
	return ((x = std::lcm(x, xs)), ...);
}

std::gcd(int a, int b)

*/

typedef long long ll;

void solve() {
    ll n;
    cin >> n;
    bool zero = true;
    vector<ll> v(n, 0);
    vector<ll> p(n + 1, 0);
    for(ll i = 0; i < n; i++) {
        cin >> v[i];
        p[v[i]] = i + 1;
    }

    ll maxx = p[1];

    ll md = 0;

    pair<ll,ll> s;

    for(ll i = 2; i <= n; i++) {
        //cerr << "\ni=" << i;
        if(p[i] > maxx) {
            maxx = p[i];
        }
        //cerr << "\nmaxx=" << maxx;
        //cerr << "\np[i]=" << p[i];
        if(p[i] < maxx) {
            if(maxx - p[i] > md) {
                md = maxx - p[i];
                s.first = p[i];
                s.second = maxx;
            }
        }       
    }

    if(md == 0) {
        cout << "-1";
    }else{
        cout << s.first << " " << s.second;
    }

}

int main()
{
	std::ios_base::sync_with_stdio(false);

	solve();

	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/01ms316 KiB
2Elfogadva0/07ms1268 KiB
3Elfogadva1/11ms316 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva7/71ms316 KiB
6Elfogadva2/27ms1076 KiB
7Elfogadva2/267ms8244 KiB
8Elfogadva2/286ms8244 KiB
9Elfogadva2/286ms8252 KiB
10Elfogadva2/274ms8244 KiB
11Elfogadva2/275ms8112 KiB
12Elfogadva2/279ms7988 KiB
13Elfogadva2/279ms8436 KiB
14Elfogadva2/274ms8228 KiB
15Elfogadva2/268ms8244 KiB
16Elfogadva2/279ms8244 KiB
17Elfogadva2/272ms8244 KiB
18Elfogadva2/272ms8244 KiB
19Elfogadva3/368ms8244 KiB
20Elfogadva3/367ms8244 KiB
21Elfogadva2/265ms8244 KiB
22Elfogadva2/282ms8244 KiB
23Elfogadva2/274ms8244 KiB
24Elfogadva2/267ms8244 KiB