29632023-02-06 09:55:55tamasmarkInverziócpp17Wrong answer 3/50282ms20584 KiB
// inverzio.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

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

using namespace std;
struct adat
{
    long long ertek, hely;
};

int n, i, j, maxi,kezd,veg;
deque<adat>x;
bool comp(adat a, adat b)
{
    return a.ertek > b.ertek;
}

int main()
{
    cin >> n;
    x.resize(n + 1);
    for (i = 1; i <= n; ++i)
    {
        cin >> x[i].ertek;
        x[i].hely = i;
    }
    sort(x.begin()+1, x.end(), comp);
    maxi = x[1].hely;
    for (i = 2; i <= n; ++i)
    {
        if (x[i].hely < maxi) maxi = x[i].hely;
        else if (x[i].hely - maxi > veg - kezd);
        {
            veg = x[i].hely;
            kezd = maxi;
        }
    }
    if (veg - kezd == 0) 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
base3/50
1Wrong answer0/03ms1812 KiB
2Wrong answer0/023ms3772 KiB
3Accepted1/13ms2220 KiB
4Wrong answer0/23ms2444 KiB
5Wrong answer0/73ms2548 KiB
6Wrong answer0/227ms4372 KiB
7Wrong answer0/2231ms19248 KiB
8Wrong answer0/2279ms19332 KiB
9Wrong answer0/2282ms19460 KiB
10Wrong answer0/2277ms19704 KiB
11Wrong answer0/2277ms19912 KiB
12Wrong answer0/2273ms19548 KiB
13Wrong answer0/2277ms19944 KiB
14Wrong answer0/2277ms19948 KiB
15Wrong answer0/2231ms19948 KiB
16Wrong answer0/2280ms19948 KiB
17Wrong answer0/2275ms19948 KiB
18Wrong answer0/2275ms19948 KiB
19Wrong answer0/3232ms20076 KiB
20Wrong answer0/3237ms20188 KiB
21Wrong answer0/2232ms20160 KiB
22Wrong answer0/2277ms20288 KiB
23Wrong answer0/2277ms20496 KiB
24Accepted2/2218ms20584 KiB