MAXCOUNT:showing wrong answer

#include <stdio.h>
#include <stdlib.h>

     int main()
{
int t;
scanf("%d",&t);
while(t--)
{
    int n,A[100]={0},i,j,B[10000]={0},maxm=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
        maxm=(maxm<A[i]?A[i]:maxm);
    }

    for(i=1;i<=maxm;i++)
    {
        for(j=0;j<n;j++)
        {
            if(A[j]==i)
            {
                B[i]+=1;
            }
        }
    }


    int a=0,b;
    for(i=1;i<=maxm;i++)
    {

        if(B[i]>a)
        {
          a=B[i];
          b=i;
        }
    }

    printf("%d %d\n",b,a);

}
return 0;

}

The first mistake in your code is, the declaration of array B[]. Since A[i]<=10000, that means B[10000] may be accessed according to the input which you’ll not be able to since the maximum size of B[] by your code is 10000. So, you need to change that to 10001.

Contrary test case:

1
5
10000 13 10000 13 10000 10000  // output is 13 2 as per your code

Then, the question says if two or more numbers with same count exists, you need to output the smallest. You’re not doing this check.

Contrary test case:

1
6
10000 13 10000 13 10000 13