19122022-12-09 22:40:50kdbInverziócpp11Accepted 50/5057ms8300 KiB
#include <iostream>
#include <vector>
using namespace std;

ostream& operator<<(ostream& os, vector<int>& input)
{
    for (auto i : input) os << i << " ";
    return os;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int>vec(n);
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        vec[a - 1] = i;
    }
    int i = -1, j = -1, m = -1;
    for (size_t k = 0; k < n; k++)
    {
        if (vec[k] > m) m = vec[k];
        if (m - vec[k] > j - i)
        {
            i = vec[k] + 1;
            j = m + 1;
        }
    }
    if (i == -1) cout << -1 << endl;
    else cout << i << " " << j << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1696 KiB
2Accepted0/07ms2248 KiB
3Accepted1/12ms2372 KiB
4Accepted2/22ms2556 KiB
5Accepted7/72ms2620 KiB
6Accepted2/27ms2876 KiB
7Accepted2/254ms6788 KiB
8Accepted2/254ms6704 KiB
9Accepted2/254ms6776 KiB
10Accepted2/254ms6768 KiB
11Accepted2/256ms7024 KiB
12Accepted2/252ms7104 KiB
13Accepted2/254ms7096 KiB
14Accepted2/254ms7092 KiB
15Accepted2/254ms7396 KiB
16Accepted2/256ms7700 KiB
17Accepted2/254ms7856 KiB
18Accepted2/254ms7964 KiB
19Accepted3/354ms8000 KiB
20Accepted3/352ms8008 KiB
21Accepted2/254ms8300 KiB
22Accepted2/254ms8260 KiB
23Accepted2/257ms8244 KiB
24Accepted2/254ms8284 KiB