#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 && 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 && 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 | 1872 KiB | ||||
2 | Accepted | 3ms | 2124 KiB | ||||
subtask2 | 16/16 | ||||||
3 | Accepted | 32ms | 3140 KiB | ||||
4 | Accepted | 26ms | 3304 KiB | ||||
5 | Accepted | 21ms | 3660 KiB | ||||
6 | Accepted | 32ms | 3896 KiB | ||||
7 | Accepted | 32ms | 4008 KiB | ||||
8 | Accepted | 30ms | 3972 KiB | ||||
subtask3 | 0/33 | ||||||
9 | Accepted | 3ms | 3420 KiB | ||||
10 | Accepted | 3ms | 3508 KiB | ||||
11 | Accepted | 3ms | 3508 KiB | ||||
12 | Wrong answer | 3ms | 3508 KiB | ||||
13 | Accepted | 3ms | 3508 KiB | ||||
14 | Accepted | 3ms | 3660 KiB | ||||
15 | Accepted | 3ms | 3520 KiB | ||||
subtask4 | 0/51 | ||||||
16 | Wrong answer | 61ms | 5192 KiB | ||||
17 | Accepted | 35ms | 4528 KiB | ||||
18 | Accepted | 61ms | 5280 KiB | ||||
19 | Wrong answer | 32ms | 4484 KiB | ||||
20 | Wrong answer | 32ms | 4488 KiB | ||||
21 | Wrong answer | 61ms | 5264 KiB | ||||
22 | Accepted | 61ms | 5336 KiB | ||||
23 | Accepted | 52ms | 5088 KiB | ||||
24 | Accepted | 61ms | 5224 KiB |