#include <iostream>
using namespace std;
/*
void kiirmat(int s, int o, int *m)
{
for(int i=0;i<s;i++)
{
for(int j=0;j<o;j++)
cout<<m[i*s+j]<<"\t";
cout<<endl;
}
return;
}
*/
int main()
{
int n, m;
cin>>n>>m;
int a[n], b[m];
long long int mat[n+2][m+2]={0};
/*
for(int i=0;i<n+2;i++)
for(int j=0;j<m+2;j++)
mat[i][j]=0;
*/
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<m;i++)
cin>>b[i];
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
mat[i][j]=a[i-1]*b[j-1];
}
//kiirmat[n+2, m+2, *mat]
/*
for(int i=0;i<n+2;i++)
{
for(int j=0;j<m+2;j++)
cout<<mat[i][j]<<"\t";
cout<<endl;
}
*/
int csucssz=0, anagy=0, bnagy=0;
/*
for(int i=1;i<n+1;i++)
for(int j=1;j<m+1;j++)
{
if(mat[i][j]>mat[i-1][j] && mat[i][j]>mat[i+1][j] && mat[i][j]>mat[i][j-1] && mat[i][j]>mat[i][j+1])
csucssz++;
}
*/
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;
csucssz=anagy*bnagy;
cout<<csucssz<<endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1744 KiB | ||||
2 | Accepted | 3ms | 1912 KiB | ||||
subtask2 | 0/16 | ||||||
3 | Wrong answer | 34ms | 7700 KiB | ||||
4 | Accepted | 27ms | 7672 KiB | ||||
5 | Accepted | 21ms | 7836 KiB | ||||
6 | Accepted | 32ms | 8092 KiB | ||||
7 | Accepted | 32ms | 8300 KiB | ||||
8 | Accepted | 32ms | 8276 KiB | ||||
subtask3 | 0/33 | ||||||
9 | Accepted | 9ms | 18804 KiB | ||||
10 | Accepted | 9ms | 19048 KiB | ||||
11 | Accepted | 8ms | 17620 KiB | ||||
12 | Accepted | 3ms | 3348 KiB | ||||
13 | Wrong answer | 3ms | 3272 KiB | ||||
14 | Accepted | 3ms | 3292 KiB | ||||
15 | Accepted | 9ms | 18912 KiB | ||||
subtask4 | 0/51 | ||||||
16 | Runtime error | 162ms | 523660 KiB | ||||
17 | Runtime error | 207ms | 523540 KiB | ||||
18 | Runtime error | 160ms | 523288 KiB | ||||
19 | Accepted | 34ms | 10592 KiB | ||||
20 | Accepted | 34ms | 10644 KiB | ||||
21 | Runtime error | 162ms | 523288 KiB | ||||
22 | Runtime error | 165ms | 523036 KiB | ||||
23 | Runtime error | 165ms | 523048 KiB | ||||
24 | Runtime error | 158ms | 523036 KiB |