81072024-01-12 13:44:34tamasmarkLegmesszebbi rossz sorrendű (35 pont)cpp17Wrong answer 24/3550ms4808 KiB
// legmessz ross sorrendu.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

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

using namespace std;

struct adat
{
    int ertek, index;
};
bool hasonlit(adat a, adat b)
{
    if (a.ertek > b.ertek) return 1;
    else return 0;

}
int k,v,tav;
adat maxi;
int main()
{
    int n;
    cin >> n;
    vector<adat>x(n + 1);
    for (int i = 1; i <= n; ++i)
    {
        cin >> x[i].ertek;
        x[i].index = i;
    }
    sort(x.begin()+1, x.end(), hasonlit);
    maxi.ertek=x[1].ertek;
    maxi.index = x[1].index;
    for (int i = 2; i <= n - 1; ++i)
    {
        if (maxi.index < x[i].index)
        {
            if (x[i].index - maxi.index > tav)
            {
                tav = x[i].index - maxi.index;
                k = maxi.index;
                v = x[i].index;
            }
            else if (x[i].index - maxi.index == tav && maxi.index<k)
            {
                k = maxi.index;
                v = x[i].index;
            }
        }
        else if (maxi.index > x[i].index)
        {
            maxi.ertek = x[i].ertek;
            maxi.index = x[i].index;
        }
    }
    cout << k << " " << v;
    return 0;
}
/*
10
7 2 4 17 6 5 10 10 18 19
*/
// 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
base24/35
1Accepted0/03ms1816 KiB
2Accepted0/050ms3356 KiB
3Wrong answer0/13ms2360 KiB
4Accepted1/13ms2464 KiB
5Accepted1/13ms2708 KiB
6Accepted1/13ms2588 KiB
7Accepted1/13ms2588 KiB
8Accepted1/13ms2596 KiB
9Accepted1/13ms2676 KiB
10Accepted1/14ms2688 KiB
11Accepted1/14ms2908 KiB
12Wrong answer0/219ms3568 KiB
13Wrong answer0/221ms3936 KiB
14Wrong answer0/224ms4112 KiB
15Wrong answer0/216ms3624 KiB
16Wrong answer0/224ms4036 KiB
17Accepted2/235ms4168 KiB
18Accepted2/239ms4556 KiB
19Accepted2/243ms4808 KiB
20Accepted2/246ms4768 KiB
21Accepted2/248ms4752 KiB
22Accepted2/250ms4748 KiB
23Accepted2/239ms4752 KiB
24Accepted2/239ms4748 KiB