65402023-12-08 10:31:26tamasmarkInverziócpp17Accepted 50/50289ms11808 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
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1816 KiB
2Accepted0/023ms2940 KiB
3Accepted1/13ms2264 KiB
4Accepted2/23ms2444 KiB
5Accepted7/73ms2736 KiB
6Accepted2/226ms3456 KiB
7Accepted2/2224ms10932 KiB
8Accepted2/2268ms11044 KiB
9Accepted2/2272ms11308 KiB
10Accepted2/2266ms11536 KiB
11Accepted2/2268ms11612 KiB
12Accepted2/2263ms11484 KiB
13Accepted2/2266ms11692 KiB
14Accepted2/2289ms11692 KiB
15Accepted2/2223ms11808 KiB
16Accepted2/2268ms11692 KiB
17Accepted2/2268ms11696 KiB
18Accepted2/2266ms11804 KiB
19Accepted3/3221ms11692 KiB
20Accepted3/3229ms11688 KiB
21Accepted2/2222ms11692 KiB
22Accepted2/2266ms11688 KiB
23Accepted2/2268ms11712 KiB
24Accepted2/2211ms11696 KiB