#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 && m==1)
csucssz=1;
else 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 | 1880 KiB | ||||
2 | Accepted | 3ms | 2116 KiB | ||||
subtask2 | 16/16 | ||||||
3 | Accepted | 32ms | 3128 KiB | ||||
4 | Accepted | 26ms | 3360 KiB | ||||
5 | Accepted | 20ms | 3508 KiB | ||||
6 | Accepted | 32ms | 3740 KiB | ||||
7 | Accepted | 32ms | 3800 KiB | ||||
8 | Accepted | 30ms | 3912 KiB | ||||
subtask3 | 33/33 | ||||||
9 | Accepted | 3ms | 3436 KiB | ||||
10 | Accepted | 3ms | 3640 KiB | ||||
11 | Accepted | 3ms | 3672 KiB | ||||
12 | Accepted | 3ms | 3672 KiB | ||||
13 | Accepted | 3ms | 3912 KiB | ||||
14 | Accepted | 3ms | 4272 KiB | ||||
15 | Accepted | 3ms | 4176 KiB | ||||
subtask4 | 0/51 | ||||||
16 | Wrong answer | 59ms | 5844 KiB | ||||
17 | Accepted | 34ms | 5184 KiB | ||||
18 | Accepted | 64ms | 5916 KiB | ||||
19 | Accepted | 30ms | 5008 KiB | ||||
20 | Accepted | 32ms | 5012 KiB | ||||
21 | Wrong answer | 59ms | 5916 KiB | ||||
22 | Accepted | 59ms | 5992 KiB | ||||
23 | Accepted | 52ms | 5984 KiB | ||||
24 | Accepted | 59ms | 6316 KiB |