Devu and friendship testing

Description:

Devu has n weird friends. Its his birthday today, so they thought that this is the best occasion for testing their friendship with him. They put up conditions before Devu that they will break the friendship unless he gives them a grand party on their chosen day. Formally, ith friend will break his friendship if he does not receive a grand party on dith day. Devu despite being as rich as Gatsby, is quite frugal and can give at most one grand party daily. Also, he wants to invite only one person in a party. So he just wonders what is the maximum number of friendships he can save. Please help Devu in this tough task !! Input The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. First line will contain a single integer denoting n. Second line will contain n space separated integers where ith integer corresponds to the day dith as given in the problem. Output Print a single line corresponding to the answer of the problem. Constraints 1<= T <= 104 1 <= n<= 50 1 <= di<= 100 Explanation Example case 1. Devu can give party to second friend on day 2 and first friend on day 3, so he can save both his friendships. Example case 2. Both the friends want a party on day 1, and as the Devu can not afford more than one party a day, so he can save only one of the friendships, so answer is 1. Test Case 1 Input (stdin) 2 2 3 2 2 1 1 Expected Output 2 1 Test Case 2 Input (stdin) 2 4 3 2 1 4 2 6 9 Expected Output 4 2

Program :

#include<stdio.h>

#include<string.h>


void code()

{

    int n,i,ele,a[101]={0},count=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)

    {

        scanf("%d",&ele);

        a[ele]++;

    }


    for(i=0;i<101;i++)

    {

        if(a[i])

            count++;

    }

   

    printf("%d\n",count);

}


int main()

{

    int t,i;

    scanf("%d",&t);

    for(i=0;i<t;i++)

        code();

    return 0;

}