6540 2023. 12. 08 10:31:26 tamasmark Inverzió cpp17 Elfogadva 50/50 289ms 11808 KiB
// inverzio.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <deque>
#include <algorithm>
#include<climits>

using namespace std;

struct adat
{
    int szam, hely;
};
bool hasonlit(adat a, adat b)
{
    if (a.szam > b.szam) return 1;
    else return 0;
}
deque<adat>x;
int  i, n, j, k,kezd,veg;
adat mini, maxi;

int main()
{
    cin >> n;
    x.resize(n + 1);
    for (i = 1; i <= n; ++i)
    {
        cin >> x[i].szam;
        x[i].hely = i;
    }
    sort(x.begin(), x.end(), hasonlit);
    mini.szam = x[1].hely;
    for (i = 2; i <= n; ++i)
    {
        if (x[i].hely < mini.szam) mini.szam = x[i].hely;
        else if (x[i].hely - mini.szam > veg-kezd)
        {
            kezd = mini.szam;
            veg = x[i].hely;
        }
    }
    if (!(veg - kezd)) cout << -1;
    else cout << kezd << " " << veg;
    return 0;
}
/*
5
4 3 5 1 2


*/
// 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 50/50
1 Elfogadva 0/0 3ms 1816 KiB
2 Elfogadva 0/0 23ms 2940 KiB
3 Elfogadva 1/1 3ms 2264 KiB
4 Elfogadva 2/2 3ms 2444 KiB
5 Elfogadva 7/7 3ms 2736 KiB
6 Elfogadva 2/2 26ms 3456 KiB
7 Elfogadva 2/2 224ms 10932 KiB
8 Elfogadva 2/2 268ms 11044 KiB
9 Elfogadva 2/2 272ms 11308 KiB
10 Elfogadva 2/2 266ms 11536 KiB
11 Elfogadva 2/2 268ms 11612 KiB
12 Elfogadva 2/2 263ms 11484 KiB
13 Elfogadva 2/2 266ms 11692 KiB
14 Elfogadva 2/2 289ms 11692 KiB
15 Elfogadva 2/2 223ms 11808 KiB
16 Elfogadva 2/2 268ms 11692 KiB
17 Elfogadva 2/2 268ms 11696 KiB
18 Elfogadva 2/2 266ms 11804 KiB
19 Elfogadva 3/3 221ms 11692 KiB
20 Elfogadva 3/3 229ms 11688 KiB
21 Elfogadva 2/2 222ms 11692 KiB
22 Elfogadva 2/2 266ms 11688 KiB
23 Elfogadva 2/2 268ms 11712 KiB
24 Elfogadva 2/2 211ms 11696 KiB