115792024-10-27 13:33:53balintCsúcsokpython3Wrong answer 0/100101ms18316 KiB
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    A = [-1] + A + [-1]
    B = [-1] + B + [-1]
    # Create the height matrix H[i][j] = A[i] * B[j]
    # heights = [[A[i] + B[j] for j in range(M)] for i in range(N)]
   
    A_peaks = 0
    if A[0] > A[1]:
        A_peaks+=1
    for i in range(1, N-1):
        if A[i-1] < A[i] > A[i+1]:
            A_peaks+=1
    if A[-1] > A[-2]:
        A_peaks+=1

    if M == 1:
        B_peaks = 1
    else:
        B_peaks= 0
        if B[0] > B[1]:
            B_peaks+=1
        for i in range(1, M-1):
            if B[i-1] < B[i] > B[i+1]:
                B_peaks+=1
        if B[-1] > B[-2]:
            B_peaks+=1

    print(A_peaks * B_peaks)
main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer17ms3124 KiB
2Wrong answer16ms3136 KiB
subtask20/16
3Wrong answer61ms14612 KiB
4Wrong answer57ms13152 KiB
5Wrong answer46ms5932 KiB
6Wrong answer57ms14612 KiB
7Accepted57ms15132 KiB
8Wrong answer54ms14104 KiB
subtask30/33
9Wrong answer17ms3452 KiB
10Accepted17ms3316 KiB
11Wrong answer17ms3124 KiB
12Wrong answer17ms3128 KiB
13Wrong answer17ms3132 KiB
14Wrong answer17ms3132 KiB
15Wrong answer17ms3528 KiB
subtask40/51
16Wrong answer100ms18212 KiB
17Wrong answer59ms15128 KiB
18Accepted94ms17888 KiB
19Wrong answer57ms14748 KiB
20Wrong answer57ms14732 KiB
21Wrong answer93ms18316 KiB
22Wrong answer101ms18048 KiB
23Accepted83ms17696 KiB
24Wrong answer92ms17732 KiB