#include <iostream>
using namespace std;
int main()
{
int n, m;
cin>>n>>m;
int a[n],b[m];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<m;i++)
{
cin>>b[i];
}
int anagy=0,bnagy=0;
long long int csucssz=0;
if (a[0]>a[1])
anagy++;
for(int i=1;i<n-1;i++)
if (a[i]>a[i-1] && a[i]>a[i+1])
anagy++;
if (a[n-1]>a[n-2])
anagy++;
if (b[0]>b[1])
bnagy++;
for(int i=1;i<m-1;i++)
if (b[i]>b[i-1] && b[i]>b[i+1])
bnagy++;
if (b[m-1]>b[m-2])
bnagy++;
if (n==1)
csucssz=bnagy;
else if (m==1)
csucssz=anagy;
else
csucssz=anagy*bnagy;
cout << csucssz << endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1752 KiB | ||||
2 | Accepted | 3ms | 1912 KiB | ||||
subtask2 | 16/16 | ||||||
3 | Accepted | 30ms | 2768 KiB | ||||
4 | Accepted | 25ms | 3140 KiB | ||||
5 | Accepted | 20ms | 3412 KiB | ||||
6 | Accepted | 30ms | 3512 KiB | ||||
7 | Accepted | 30ms | 3640 KiB | ||||
8 | Accepted | 28ms | 3736 KiB | ||||
subtask3 | 33/33 | ||||||
9 | Accepted | 3ms | 3396 KiB | ||||
10 | Accepted | 3ms | 3364 KiB | ||||
11 | Accepted | 4ms | 3380 KiB | ||||
12 | Accepted | 3ms | 3372 KiB | ||||
13 | Accepted | 3ms | 3620 KiB | ||||
14 | Accepted | 3ms | 3740 KiB | ||||
15 | Accepted | 3ms | 3968 KiB | ||||
subtask4 | 0/51 | ||||||
16 | Wrong answer | 57ms | 5740 KiB | ||||
17 | Accepted | 32ms | 4968 KiB | ||||
18 | Accepted | 59ms | 5468 KiB | ||||
19 | Accepted | 30ms | 4824 KiB | ||||
20 | Accepted | 30ms | 4936 KiB | ||||
21 | Wrong answer | 57ms | 5832 KiB | ||||
22 | Accepted | 59ms | 5868 KiB | ||||
23 | Accepted | 50ms | 5636 KiB | ||||
24 | Accepted | 59ms | 5976 KiB |