#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;
}
*/
/*
4 5
3 2 8 4
8 5 6 1 3
*/
int main()
{
int n, m;
cin>>n>>m;
int a[n],b[m];
int mat[n+2][m+2];
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;
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++;
}
cout << csucssz << endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1912 KiB | ||||
2 | Accepted | 3ms | 2028 KiB | ||||
subtask2 | 16/16 | ||||||
3 | Accepted | 32ms | 5336 KiB | ||||
4 | Accepted | 26ms | 5212 KiB | ||||
5 | Accepted | 20ms | 5404 KiB | ||||
6 | Accepted | 32ms | 5412 KiB | ||||
7 | Accepted | 32ms | 5532 KiB | ||||
8 | Accepted | 30ms | 5684 KiB | ||||
subtask3 | 33/33 | ||||||
9 | Accepted | 8ms | 10852 KiB | ||||
10 | Accepted | 8ms | 10664 KiB | ||||
11 | Accepted | 8ms | 10128 KiB | ||||
12 | Accepted | 3ms | 3012 KiB | ||||
13 | Accepted | 3ms | 3008 KiB | ||||
14 | Accepted | 3ms | 3008 KiB | ||||
15 | Accepted | 8ms | 11128 KiB | ||||
subtask4 | 0/51 | ||||||
16 | Runtime error | 165ms | 523728 KiB | ||||
17 | Runtime error | 164ms | 523716 KiB | ||||
18 | Runtime error | 158ms | 523692 KiB | ||||
19 | Accepted | 32ms | 7108 KiB | ||||
20 | Accepted | 32ms | 7108 KiB | ||||
21 | Runtime error | 162ms | 523600 KiB | ||||
22 | Runtime error | 159ms | 523604 KiB | ||||
23 | Runtime error | 160ms | 523436 KiB | ||||
24 | Runtime error | 162ms | 523428 KiB |