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()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Runtime error | 16ms | 3128 KiB | ||||
2 | Accepted | 16ms | 3128 KiB | ||||
subtask2 | 0/16 | ||||||
3 | Runtime error | 43ms | 14492 KiB | ||||
4 | Runtime error | 45ms | 12984 KiB | ||||
5 | Runtime error | 34ms | 5616 KiB | ||||
6 | Runtime error | 43ms | 14716 KiB | ||||
7 | Runtime error | 43ms | 14668 KiB | ||||
8 | Runtime error | 46ms | 14120 KiB | ||||
subtask3 | 0/33 | ||||||
9 | Accepted | 16ms | 3440 KiB | ||||
10 | Accepted | 17ms | 3300 KiB | ||||
11 | Accepted | 17ms | 3116 KiB | ||||
12 | Accepted | 16ms | 3144 KiB | ||||
13 | Runtime error | 17ms | 3188 KiB | ||||
14 | Accepted | 16ms | 3080 KiB | ||||
15 | Accepted | 16ms | 3176 KiB | ||||
subtask4 | 51/51 | ||||||
16 | Accepted | 90ms | 18320 KiB | ||||
17 | Accepted | 59ms | 15188 KiB | ||||
18 | Accepted | 92ms | 17776 KiB | ||||
19 | Accepted | 57ms | 14616 KiB | ||||
20 | Accepted | 57ms | 14612 KiB | ||||
21 | Accepted | 96ms | 18332 KiB | ||||
22 | Accepted | 96ms | 18080 KiB | ||||
23 | Accepted | 75ms | 17556 KiB | ||||
24 | Accepted | 89ms | 17696 KiB |