115812024-10-27 13:45:27balintCsúcsokpython3Accepted 100/100101ms18336 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]

    A_peaks = 0
    for i in range(1, N+1):
        if A[i-1] < A[i] > A[i+1]:
            A_peaks+=1

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

    print(A_peaks * B_peaks)
main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted16ms3136 KiB
2Accepted16ms3128 KiB
subtask216/16
3Accepted59ms14680 KiB
4Accepted54ms13152 KiB
5Accepted46ms6032 KiB
6Accepted57ms14500 KiB
7Accepted57ms15012 KiB
8Accepted59ms14216 KiB
subtask333/33
9Accepted17ms3276 KiB
10Accepted16ms3128 KiB
11Accepted17ms3320 KiB
12Accepted16ms3128 KiB
13Accepted16ms3132 KiB
14Accepted14ms3060 KiB
15Accepted17ms3312 KiB
subtask451/51
16Accepted97ms18336 KiB
17Accepted61ms14912 KiB
18Accepted90ms17772 KiB
19Accepted59ms14636 KiB
20Accepted59ms14608 KiB
21Accepted101ms18332 KiB
22Accepted94ms18028 KiB
23Accepted86ms17556 KiB
24Accepted98ms17804 KiB