Is my algorithm correct??
#include <iostream>
#include <algorithm>
using namespace std;
long a[15001],b[1000001],i,j,k,n,m;
main(void){
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&a[i]);
scanf("%d",&m);
for(i=0;i<m;i++)scanf("%d",&b[i]);
make_heap(b,b+m);
sort_heap(b,b+m);
k=i=j=0;
while(i<n && j<m){
if (a[i]<b[j])i++; else
if (a[i]>b[j])j++; else
{j++;k++;};
};
printf("%d\n",k);
};
I got WA on test 10, why?? I think there is everything OK.
Can you help me??