8064 2024. 01. 12 11:46:35 bzsofia Legmesszebbi rossz sorrendű (35 pont) cpp17 Hibás válasz 3/35 273ms 5368 KiB
// Sorrend.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <climits>
#include <vector>

using namespace std;

int i, n, j, maxt=INT_MIN, maxi, maxj;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    vector <int> x(n + 1);

    for (i = 1; i <= n; ++i)
    {
        cin >> x[i];
    }

    i = 1;
    j = n;
    while (i<j && j - i + 1>maxt)
    {
        if (x[i] > x[j])
        {
            maxt = j - i + 1;
            maxi = i;
            maxj = j;
            j = n;
            ++i;
        }
        else
        {
            if (i + 1 == j || j - i + 2 == maxt)
            {
                ++i;
                j = n;
            }
            else
            {
                --j;
            }
        }
    }

    if (maxi == 0 && maxj == 0) cout << "-1";
    else cout << maxi << " " << maxj;

    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
Részfeladat Összpont Teszt Verdikt Idő Memória
base 3/35
1 Elfogadva 0/0 3ms 1832 KiB
2 Hibás válasz 0/0 14ms 2872 KiB
3 Elfogadva 1/1 3ms 2380 KiB
4 Elfogadva 1/1 3ms 2560 KiB
5 Hibás válasz 0/1 3ms 2652 KiB
6 Elfogadva 1/1 2ms 2736 KiB
7 Hibás válasz 0/1 3ms 2740 KiB
8 Hibás válasz 0/1 3ms 2876 KiB
9 Hibás válasz 0/1 3ms 3088 KiB
10 Hibás válasz 0/1 3ms 3316 KiB
11 Hibás válasz 0/1 3ms 3648 KiB
12 Hibás válasz 0/2 8ms 4012 KiB
13 Hibás válasz 0/2 8ms 4228 KiB
14 Hibás válasz 0/2 8ms 4180 KiB
15 Hibás válasz 0/2 6ms 4264 KiB
16 Hibás válasz 0/2 8ms 4436 KiB
17 Hibás válasz 0/2 10ms 4520 KiB
18 Hibás válasz 0/2 13ms 4780 KiB
19 Hibás válasz 0/2 13ms 4996 KiB
20 Hibás válasz 0/2 14ms 5128 KiB
21 Hibás válasz 0/2 14ms 5368 KiB
22 Hibás válasz 0/2 14ms 5336 KiB
23 Időlimit túllépés 0/2 254ms 4592 KiB
24 Időlimit túllépés 0/2 273ms 4484 KiB