29622023-02-06 09:37:20tamasmarkInverziócpp17Time limit exceeded 9/50600ms11544 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 = -99999;
    for (i = 1; i <= n-1; ++i)
    {
        for (j = i + 1; j <= n; ++j)
        {
            if (x[i].hely<x[j].hely && x[i].ertek>x[j].ertek)
            {
                if (maxi < x[j].hely - x[i].hely)
                {
                    maxi = x[j].hely - x[i].hely;
                    kezd = x[i].hely;
                    veg = x[j].hely;
                }
            }
        }
    }
    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
base9/50
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0600ms2108 KiB
3Wrong answer0/13ms2336 KiB
4Accepted2/27ms2596 KiB
5Accepted7/74ms2792 KiB
6Time limit exceeded0/2600ms3028 KiB
7Time limit exceeded0/2584ms10708 KiB
8Time limit exceeded0/2568ms10600 KiB
9Time limit exceeded0/2566ms10812 KiB
10Time limit exceeded0/2555ms10932 KiB
11Time limit exceeded0/2575ms10984 KiB
12Time limit exceeded0/2568ms10676 KiB
13Time limit exceeded0/2551ms10860 KiB
14Time limit exceeded0/2560ms10932 KiB
15Time limit exceeded0/2573ms11084 KiB
16Time limit exceeded0/2558ms11004 KiB
17Time limit exceeded0/2560ms11008 KiB
18Time limit exceeded0/2560ms11132 KiB
19Time limit exceeded0/3563ms11144 KiB
20Time limit exceeded0/3541ms11340 KiB
21Time limit exceeded0/2564ms11452 KiB
22Time limit exceeded0/2573ms11464 KiB
23Time limit exceeded0/2564ms11504 KiB
24Time limit exceeded0/2580ms11544 KiB