246612026-02-13 11:36:52VikiVölgy (100 pont)python3Wrong answer 25/100190ms7984 KiB
Ne = int(input()) #elemek szama
M = [] #magasagok
for i in range (Ne):
    M.append(int(input()))
a = 0 #aktualis hossz
h = 0 #eddigi leghosszabb
L = 0 #jelenlegi legmagasabb
i = 0
Si = 0
Ei = Ne
N = [0]

if len(M) > 2: #minimum harom ponthoz
    while M[i] <= M[i+1] and len(M) > i+1: #felesleges elemek a lista elejetol
        Si += 1
        i += 1
    M.reverse() #hogy hátulról kerüljenek le
    while M[i] <= M[i+1] and len(M) > i+1: #felesleges elemek a lista hatuljatol
        Ei -= 1
        i += 1
    M.reverse() #eredeti sorrendre
    N = M[Si:(Ei+1)]
    M = N
    N = [0]
    #eredeti sorrend, sor eleji-végi felesleges elemek nekul
    i=0
    for i in range(len(M)):
        if M[i] >= L: #ha a jelenlegi elem nagyobb vagy egyenlo az elozo legnagyobbnal
            if a>h: #ha aktualis befejezett hossz hagyobb az eddigi legnagyobbnal
                h = a #eddigi leghosszabb = aktualis hosszaval
                a = 0 #aktualist lenullazzuk
            L = M[i] #eddigi legmagasabb pont legyen a jelenlegi
        else: #ha jelenlegi elem kisebb az eddigi legmagasabbnal
            a += 1 #jelenlegi hossz novekszik
    i = 0 #indexet lenullazzuk
    
    M.reverse() #hogy elorol nezhessuk hogy utolso elem e a legmagasabb -> idealis allapot
    if M[i] != L: #ha 0. elem nem az a legmagabb ertek
        L = 0 #eddigi legmagasabb pontot lenullazzuk
        a = 0
        for i in range(len(M)): #uj M lista
            if M[i] >= L: #ha a jelenlegi elem nagyobb az elozo legnagyobbnal
                if a>h:
                    h = a
                    a = 0
                L = M[i]
            else:
                a += 1

if h <= 1: #ha nincs völgy
    print("-1")
else:
    print(h+1)
SubtaskSumTestVerdictTimeMemory
base25/100
1Accepted0/016ms3316 KiB
2Wrong answer0/017ms3244 KiB
3Wrong answer0/516ms3088 KiB
4Accepted5/516ms3124 KiB
5Wrong answer0/517ms3124 KiB
6Accepted5/517ms3124 KiB
7Runtime error0/517ms3124 KiB
8Wrong answer0/517ms3212 KiB
9Runtime error0/517ms3564 KiB
10Wrong answer0/517ms3144 KiB
11Accepted5/525ms3376 KiB
12Wrong answer0/532ms3380 KiB
13Wrong answer0/534ms3636 KiB
14Wrong answer0/534ms3640 KiB
15Wrong answer0/5180ms7808 KiB
16Wrong answer0/5186ms7984 KiB
17Runtime error0/5188ms7108 KiB
18Wrong answer0/5172ms7616 KiB
19Wrong answer0/5180ms7808 KiB
20Accepted5/5165ms7824 KiB
21Accepted5/5190ms7888 KiB
22Wrong answer0/5166ms7820 KiB