Problem
There are students in a class, where the -th student has a score of .
The -th student will boast if and only if the number of students scoring less than or equal is greater than the number of students scoring greater than .
Find the number of students who will boast.
Input Format
- The first line contains - the number of test cases. Then the test cases follow.
- The first line of each test case contains a single integer - the number of students.
- The second line of each test case contains integers - the scores of the students.
Output Format
For each test case, output in a single line the number of students who will boast.
Constraints
Sample 1:
3 3 100 100 100 3 2 1 3 4 30 1 30 30
3 2 3
Explanation:
- Test case : All three students got the highest score. So all three of them will boast.
- Test case : Only the student with score will not be able to boast.
- Test case : Only the student with score will not be able to boast.
Program :
#include <stdio.h>
int main(void) {
// your code goes here
int t,n;
int i,j;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
int c=0,c1=0,c2=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i]>=a[j])
{
c1++;
}
else
{
c2++;
}
}
if(c1>c2)
{
c++;
}
c1=0;
c2=0;
}
printf("%d\n",c);
}
return 0;
}
0 Comments