115782024-10-27 13:27:05balintCsúcsokpython3Runtime error 51/10096ms18332 KiB
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    # 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


    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
1Runtime error16ms3128 KiB
2Accepted16ms3128 KiB
subtask20/16
3Runtime error43ms14492 KiB
4Runtime error45ms12984 KiB
5Runtime error34ms5616 KiB
6Runtime error43ms14716 KiB
7Runtime error43ms14668 KiB
8Runtime error46ms14120 KiB
subtask30/33
9Accepted16ms3440 KiB
10Accepted17ms3300 KiB
11Accepted17ms3116 KiB
12Accepted16ms3144 KiB
13Runtime error17ms3188 KiB
14Accepted16ms3080 KiB
15Accepted16ms3176 KiB
subtask451/51
16Accepted90ms18320 KiB
17Accepted59ms15188 KiB
18Accepted92ms17776 KiB
19Accepted57ms14616 KiB
20Accepted57ms14612 KiB
21Accepted96ms18332 KiB
22Accepted96ms18080 KiB
23Accepted75ms17556 KiB
24Accepted89ms17696 KiB