19112022-12-09 22:39:30kdbInverziócpp11Wrong answer 47/5061ms8320 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;
        }
    }
    cout << i << " " << j << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base47/50
1Accepted0/03ms1824 KiB
2Accepted0/07ms2360 KiB
3Wrong answer0/12ms2268 KiB
4Accepted2/22ms2432 KiB
5Accepted7/72ms2636 KiB
6Accepted2/27ms3020 KiB
7Accepted2/256ms6880 KiB
8Accepted2/257ms6824 KiB
9Accepted2/259ms6820 KiB
10Accepted2/259ms7076 KiB
11Accepted2/257ms7280 KiB
12Accepted2/256ms7364 KiB
13Accepted2/257ms7444 KiB
14Accepted2/257ms7492 KiB
15Accepted2/257ms7736 KiB
16Accepted2/257ms7688 KiB
17Accepted2/259ms7684 KiB
18Accepted2/261ms7892 KiB
19Accepted3/357ms8100 KiB
20Accepted3/357ms8044 KiB
21Accepted2/257ms8044 KiB
22Accepted2/257ms8092 KiB
23Accepted2/257ms8092 KiB
24Wrong answer0/257ms8320 KiB