21952022-12-31 09:36:371478Inverziócpp11Wrong answer 47/50178ms8004 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];
        }
    }

    cout<<ansK<<" "<<ansV;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base47/50
1Accepted0/03ms2088 KiB
2Accepted0/017ms2456 KiB
3Wrong answer0/12ms2252 KiB
4Accepted2/22ms2500 KiB
5Accepted7/72ms2620 KiB
6Accepted2/217ms2880 KiB
7Accepted2/2172ms6776 KiB
8Accepted2/2178ms6980 KiB
9Accepted2/2178ms7300 KiB
10Accepted2/2175ms7248 KiB
11Accepted2/2173ms7248 KiB
12Accepted2/2171ms6868 KiB
13Accepted2/2173ms7240 KiB
14Accepted2/2173ms7564 KiB
15Accepted2/2171ms7636 KiB
16Accepted2/2178ms7696 KiB
17Accepted2/2174ms7632 KiB
18Accepted2/2177ms7652 KiB
19Accepted3/3172ms7652 KiB
20Accepted3/3172ms7912 KiB
21Accepted2/2172ms7972 KiB
22Accepted2/2174ms7928 KiB
23Accepted2/2175ms8004 KiB
24Wrong answer0/2171ms7860 KiB