29822023-02-07 09:20:49zsebiInverziócpp11Accepted 50/50244ms19748 KiB
// inverzio.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#include <algorithm>

#define ll long long
using namespace std;

ll n;

int main()
{
    cin >> n;
    vector<pair<ll,ll>>x(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> x[i].first;
        x[i].second = i + 1;
    }
    sort(x.begin(), x.end(), [](pair<ll,ll> a, pair<ll,ll> b)
        {
            return a.first > b.first;
        });
    ll mini = x[0].second,v=0,k=0;
    for (int i = 1; i < n; ++i)
    {
        mini = min(x[i].second, mini);
        if(x[i].second - mini > v - k)
        {
            v = x[i].second;
            k = mini;
        }
    }
    if (k == v)cout << "-1";
    else cout << k << " " << v;
    return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1808 KiB
2Accepted0/019ms3408 KiB
3Accepted1/13ms2272 KiB
4Accepted2/23ms2500 KiB
5Accepted7/73ms2716 KiB
6Accepted2/223ms4132 KiB
7Accepted2/2192ms18432 KiB
8Accepted2/2232ms18584 KiB
9Accepted2/2233ms18668 KiB
10Accepted2/2231ms18664 KiB
11Accepted2/2234ms18748 KiB
12Accepted2/2229ms18404 KiB
13Accepted2/2231ms18880 KiB
14Accepted2/2231ms18880 KiB
15Accepted2/2193ms19136 KiB
16Accepted2/2233ms19120 KiB
17Accepted2/2231ms19168 KiB
18Accepted2/2239ms19220 KiB
19Accepted3/3194ms19300 KiB
20Accepted3/3197ms19300 KiB
21Accepted2/2193ms19432 KiB
22Accepted2/2234ms19640 KiB
23Accepted2/2244ms19728 KiB
24Accepted2/2185ms19748 KiB