CODING QUESTION 2
Average Flex (CODECHEF OCTOBER COOK-OFF CHALLENGE 2021)
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 first line of each test case contains a single integer
- The second line of each test case contains integers
Output Format
For each test case, output in a single line the number of students who will boast.
Constraints
Sample Input 1
3
3
100 100 100
3
2 1 3
4
30 1 30 30
Sample Output 1
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.
CODE:
for i in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
c1=0
c2=0
c=0
for i in range(0,n):
c1=0
c2=0
for j in range(0,n):
if l[j]<=l[i]:
c1+=1
if l[j]>l[i]:
c2+=1
#print(c1,c2)
if(c1>c2):
c+=1
print(c)
LINK: https://www.codechef.com/COOK134C/problems/AVGFLEX/
Please follow the page for more updates....!
Comments
Post a Comment