#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;
for(int i = 0; i<n;i++)
{
cin>>a[i];
if(i==1)
{
if (n==2 && a[0]!=a[1])
maxa++;
else if (n>2 && a[0]>a[1])
maxa++;
}
else if (n>2 && i<n-1 && a[i]<a[i-1] && a[i-1]>a[i-2])
maxa++;
else if (n>2 && i==n-1 && ((a[n-1]>a[n-2]) || (a[n-1]<a[n-2] && a[n-2]>a[n-3])))
maxa++;
// cout<<endl<<maxa<<endl;
}
for(int i = 0; i<m;i++)
{
cin>>b[i];
if(i==1)
{
if(m==2 && b[0]!=b[1])
maxb++;
else if (m>2 && b[0]>b[1])
maxb++;
}
else if (m>2 && i<m-1 && b[i]<b[i-1] && b[i-1]>b[i-2])
maxb++;
else if (m>2 && i==m-1 && ((b[m-1]>b[m-2]) || (b[m-1]<b[m-2] && b[m-2]>b[m-3])))
maxb++;
//cout<<endl<<maxb<<endl;
}
//cout<<maxa<< " " << maxb<<endl;
cout<<maxa*maxb;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1788 KiB | ||||
2 | Accepted | 3ms | 2032 KiB | ||||
subtask2 | 16/16 | ||||||
3 | Accepted | 30ms | 3012 KiB | ||||
4 | Accepted | 25ms | 3212 KiB | ||||
5 | Accepted | 20ms | 3436 KiB | ||||
6 | Accepted | 29ms | 3488 KiB | ||||
7 | Accepted | 30ms | 3760 KiB | ||||
8 | Accepted | 28ms | 3820 KiB | ||||
subtask3 | 33/33 | ||||||
9 | Accepted | 3ms | 3080 KiB | ||||
10 | Accepted | 3ms | 3204 KiB | ||||
11 | Accepted | 3ms | 3324 KiB | ||||
12 | Accepted | 3ms | 3248 KiB | ||||
13 | Accepted | 3ms | 3280 KiB | ||||
14 | Accepted | 3ms | 3248 KiB | ||||
15 | Accepted | 3ms | 3256 KiB | ||||
subtask4 | 0/51 | ||||||
16 | Wrong answer | 57ms | 4792 KiB | ||||
17 | Accepted | 32ms | 4056 KiB | ||||
18 | Accepted | 57ms | 4800 KiB | ||||
19 | Accepted | 29ms | 4016 KiB | ||||
20 | Accepted | 30ms | 4140 KiB | ||||
21 | Wrong answer | 57ms | 5124 KiB | ||||
22 | Accepted | 57ms | 4852 KiB | ||||
23 | Accepted | 50ms | 4760 KiB | ||||
24 | Accepted | 57ms | 4968 KiB |