128492025-01-02 13:29:31BucsMateInverziócpp17Hibás válasz 47/50195ms4312 KiB
#include <iostream>

using namespace std;

int sor[500001];
int poz[500001];

int main()
{
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> sor[i];
        poz[sor[i]] = i;
    }
    int max_tav = 0;
    int index2 = N;
    int megoldas_bal, megoldas_jobb;
    for(int num = N; num >= 2; num--){
        int index1 = poz[num];
        while(sor[index2] >= num && index2 > 0){
            index2--;
        }
        if(index2 > 0 && index1 < index2 && index2 - index1 > max_tav){
            max_tav = index2 - index1;
            megoldas_bal = index1;
            megoldas_jobb = index2;
        }
    }
    cout << megoldas_bal << " " << megoldas_jobb << endl;
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base47/50
1Elfogadva0/01ms320 KiB
2Elfogadva0/017ms568 KiB
3Hibás válasz0/11ms336 KiB
4Elfogadva2/21ms500 KiB
5Elfogadva7/71ms320 KiB
6Elfogadva2/217ms560 KiB
7Elfogadva2/2174ms4188 KiB
8Elfogadva2/2180ms4152 KiB
9Elfogadva2/2181ms4248 KiB
10Elfogadva2/2177ms4080 KiB
11Elfogadva2/2178ms4152 KiB
12Elfogadva2/2174ms4152 KiB
13Elfogadva2/2177ms4312 KiB
14Elfogadva2/2180ms4124 KiB
15Elfogadva2/2174ms4152 KiB
16Elfogadva2/2178ms4092 KiB
17Elfogadva2/2178ms4152 KiB
18Elfogadva2/2179ms4244 KiB
19Elfogadva3/3174ms4152 KiB
20Elfogadva3/3173ms4224 KiB
21Elfogadva2/2173ms4152 KiB
22Elfogadva2/2180ms4288 KiB
23Elfogadva2/2195ms4152 KiB
24Hibás válasz0/2172ms4152 KiB