21962022-12-31 09:38:231478Inverziócpp11Elfogadva 50/50182ms8548 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int main()
{
    // ifstream cin("be.txt");
    int n;
    cin >> n;

    vector<int> v(n + 1);
    for (int i = 1; i <= n; i++)
    {
        int a;
        cin >> a;
        v[a] = i;
    }

    int mini = v[n];
    int ans = 0;
    int ansK = n, ansV = n;
    for (int i = n - 1; i >= 1; i--)
    {
        int tav = v[i] - mini;
        if (v[i] > mini && tav > ans)
        {
            ans = tav;
            ansK = mini;
            ansV = v[i];
        }
        if (v[i] < mini)
        {
            mini = v[i];
        }
    }

    if (ans == 0)
        cout << -1;
    else
    {
        cout << ansK << " " << ansV;
    }

    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1680 KiB
2Elfogadva0/017ms2244 KiB
3Elfogadva1/12ms2376 KiB
4Elfogadva2/22ms2364 KiB
5Elfogadva7/72ms2360 KiB
6Elfogadva2/217ms2548 KiB
7Elfogadva2/2174ms6352 KiB
8Elfogadva2/2180ms6300 KiB
9Elfogadva2/2182ms6748 KiB
10Elfogadva2/2178ms7068 KiB
11Elfogadva2/2179ms7032 KiB
12Elfogadva2/2174ms6964 KiB
13Elfogadva2/2179ms7476 KiB
14Elfogadva2/2178ms7676 KiB
15Elfogadva2/2175ms7972 KiB
16Elfogadva2/2180ms7800 KiB
17Elfogadva2/2181ms7864 KiB
18Elfogadva2/2179ms8120 KiB
19Elfogadva3/3174ms8340 KiB
20Elfogadva3/3175ms8548 KiB
21Elfogadva2/2174ms8464 KiB
22Elfogadva2/2178ms8460 KiB
23Elfogadva2/2178ms8460 KiB
24Elfogadva2/2173ms8528 KiB