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()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 17ms | 3124 KiB | ||||
2 | Wrong answer | 16ms | 3136 KiB | ||||
subtask2 | 0/16 | ||||||
3 | Wrong answer | 61ms | 14612 KiB | ||||
4 | Wrong answer | 57ms | 13152 KiB | ||||
5 | Wrong answer | 46ms | 5932 KiB | ||||
6 | Wrong answer | 57ms | 14612 KiB | ||||
7 | Accepted | 57ms | 15132 KiB | ||||
8 | Wrong answer | 54ms | 14104 KiB | ||||
subtask3 | 0/33 | ||||||
9 | Wrong answer | 17ms | 3452 KiB | ||||
10 | Accepted | 17ms | 3316 KiB | ||||
11 | Wrong answer | 17ms | 3124 KiB | ||||
12 | Wrong answer | 17ms | 3128 KiB | ||||
13 | Wrong answer | 17ms | 3132 KiB | ||||
14 | Wrong answer | 17ms | 3132 KiB | ||||
15 | Wrong answer | 17ms | 3528 KiB | ||||
subtask4 | 0/51 | ||||||
16 | Wrong answer | 100ms | 18212 KiB | ||||
17 | Wrong answer | 59ms | 15128 KiB | ||||
18 | Accepted | 94ms | 17888 KiB | ||||
19 | Wrong answer | 57ms | 14748 KiB | ||||
20 | Wrong answer | 57ms | 14732 KiB | ||||
21 | Wrong answer | 93ms | 18316 KiB | ||||
22 | Wrong answer | 101ms | 18048 KiB | ||||
23 | Accepted | 83ms | 17696 KiB | ||||
24 | Wrong answer | 92ms | 17732 KiB |