#include <bits/stdc++.h>
#define ll long long
#define forL(len) for (int i=1; i<=len; i++)
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N,M,a=0,b=0;
cin>>N>>M;
vector<int> A(N);
forL(N)
cin>>A[i-1];
vector<int> B(M);
forL(M)
cin>>B[i-1];
A.push_back(-1);
A.insert(A.begin(), -1);
B.push_back(-1);
B.insert(B.begin(), -1);
forL(N+1)
if (A[i] > A[i-1] && A[i] > A[i+1]) a++;
forL(M+1)
if (B[i] > B[i-1] && B[i] > B[i+1]) b++;
ll ans = a*b; cout << ans << endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 16/16 | ||||||
3 | Accepted | 10ms | 1100 KiB | ||||
4 | Accepted | 9ms | 1080 KiB | ||||
5 | Accepted | 8ms | 1088 KiB | ||||
6 | Accepted | 10ms | 1084 KiB | ||||
7 | Accepted | 10ms | 1092 KiB | ||||
8 | Accepted | 10ms | 1076 KiB | ||||
subtask3 | 33/33 | ||||||
9 | Accepted | 1ms | 320 KiB | ||||
10 | Accepted | 1ms | 508 KiB | ||||
11 | Accepted | 1ms | 320 KiB | ||||
12 | Accepted | 1ms | 320 KiB | ||||
13 | Accepted | 1ms | 320 KiB | ||||
14 | Accepted | 1ms | 320 KiB | ||||
15 | Accepted | 1ms | 320 KiB | ||||
subtask4 | 0/51 | ||||||
16 | Wrong answer | 20ms | 1592 KiB | ||||
17 | Accepted | 12ms | 1236 KiB | ||||
18 | Accepted | 20ms | 1600 KiB | ||||
19 | Accepted | 10ms | 1100 KiB | ||||
20 | Accepted | 10ms | 1080 KiB | ||||
21 | Wrong answer | 20ms | 1600 KiB | ||||
22 | Accepted | 20ms | 1592 KiB | ||||
23 | Accepted | 17ms | 1328 KiB | ||||
24 | Accepted | 20ms | 1596 KiB |