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()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 16ms | 3136 KiB | ||||
2 | Accepted | 16ms | 3128 KiB | ||||
subtask2 | 16/16 | ||||||
3 | Accepted | 59ms | 14680 KiB | ||||
4 | Accepted | 54ms | 13152 KiB | ||||
5 | Accepted | 46ms | 6032 KiB | ||||
6 | Accepted | 57ms | 14500 KiB | ||||
7 | Accepted | 57ms | 15012 KiB | ||||
8 | Accepted | 59ms | 14216 KiB | ||||
subtask3 | 33/33 | ||||||
9 | Accepted | 17ms | 3276 KiB | ||||
10 | Accepted | 16ms | 3128 KiB | ||||
11 | Accepted | 17ms | 3320 KiB | ||||
12 | Accepted | 16ms | 3128 KiB | ||||
13 | Accepted | 16ms | 3132 KiB | ||||
14 | Accepted | 14ms | 3060 KiB | ||||
15 | Accepted | 17ms | 3312 KiB | ||||
subtask4 | 51/51 | ||||||
16 | Accepted | 97ms | 18336 KiB | ||||
17 | Accepted | 61ms | 14912 KiB | ||||
18 | Accepted | 90ms | 17772 KiB | ||||
19 | Accepted | 59ms | 14636 KiB | ||||
20 | Accepted | 59ms | 14608 KiB | ||||
21 | Accepted | 101ms | 18332 KiB | ||||
22 | Accepted | 94ms | 18028 KiB | ||||
23 | Accepted | 86ms | 17556 KiB | ||||
24 | Accepted | 98ms | 17804 KiB |