#include <iostream>
using namespace std;
int main()
{
int n, m;
cin>>n>>m;
int a[n], b[m];
int maxa=0, maxb=0;
if (n==1) maxa=1;
if (m==1) maxb=1;
bool ano=false, bno=false;
for(int i = 0; i<n;i++)
{
cin>>a[i];
if(n==2)
{
if (i==1 && a[0]!=a[1])
maxa++;
}
else if (n>2)
{
if (i==1)
{
if (a[0]>a[1])
{
maxa++;
ano=false;
}
else
ano=true;
}
else if (i!=0 && i<n)
{
if (ano && a[i]<a[i-1])
{
maxa++;
ano=false;
}
else if (a[i]<=a[i-1])
{
ano==false;
}
else
ano=true;
}
}
//cout<<maxa<<" "<<ano<<endl;
}
if (ano)
maxa++;
//cout<<maxa<<endl;
for(int i = 0; i<m;i++)
{
cin>>b[i];
if(m==2)
{
if (i==1 && b[0]!=b[1])
maxb++;
}
else if (m>2)
{
if (i==1)
{
if (b[0]>b[1])
{
maxb++;
bno=false;
}
else
bno=true;
}
else if (i!=0 && i<m)
{
if (b[i]<=b[i-1])
{
if (bno)
maxb++;
bno=false;
}
else
bno=true;
}
}
// cout<<maxb<<" "<<bno<<endl;
}
if (bno)
maxb++;
//cout<<maxb<<endl;
//cout<<"+++";
cout<<maxa*maxb;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1744 KiB | ||||
2 | Accepted | 3ms | 2072 KiB | ||||
subtask2 | 0/16 | ||||||
3 | Wrong answer | 30ms | 2848 KiB | ||||
4 | Wrong answer | 25ms | 2840 KiB | ||||
5 | Wrong answer | 20ms | 3108 KiB | ||||
6 | Wrong answer | 30ms | 3324 KiB | ||||
7 | Wrong answer | 29ms | 3404 KiB | ||||
8 | Wrong answer | 29ms | 3516 KiB | ||||
subtask3 | 0/33 | ||||||
9 | Accepted | 3ms | 2852 KiB | ||||
10 | Wrong answer | 3ms | 3004 KiB | ||||
11 | Accepted | 3ms | 3132 KiB | ||||
12 | Accepted | 3ms | 3244 KiB | ||||
13 | Accepted | 3ms | 3212 KiB | ||||
14 | Accepted | 3ms | 3340 KiB | ||||
15 | Accepted | 3ms | 3428 KiB | ||||
subtask4 | 0/51 | ||||||
16 | Wrong answer | 59ms | 5096 KiB | ||||
17 | Wrong answer | 34ms | 4460 KiB | ||||
18 | Wrong answer | 59ms | 5196 KiB | ||||
19 | Wrong answer | 30ms | 4468 KiB | ||||
20 | Wrong answer | 30ms | 4576 KiB | ||||
21 | Wrong answer | 59ms | 5480 KiB | ||||
22 | Wrong answer | 59ms | 5464 KiB | ||||
23 | Wrong answer | 50ms | 5340 KiB | ||||
24 | Wrong answer | 59ms | 5572 KiB |