ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1196. History Exam

Is my algorithm correct??
Posted by David Tvaltchrelidze 20 Dec 2006 23:27
#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??