Editorial-ENCJJUN3

PROBLEM LINK:

Practice
Contest Link
Problem Link

Author: Akash Kumar Bhagat
Tester: Anjali Jha
Editorialist: Karan Ghorai

DIFFICULTY:

CAKEWALK

PROBLEM:

The problem comes down to counting the number of girls in each universities whose names does not start with the letter ‘B’ and finding the university with maximum number of such count.

QUICK EXPLANATION:

Traverse and the given array for each of the university and count the number of girls whose names does not start with the letter ‘B’.

EXPLANATION:

Traverse and the given array for each of the university and count the number of girls whose names does not start with the letter ‘B’. With this done the university with maximum of such count can be easily found out by comparing each count.

TIME COMPLEXITY:

O(N*M), where N is the number of universities and M is the number of girls in each universities.

SOLUTIONS:

Editorialist's Solution
t=int(input())

for _ in range(t):
    n=int(input())
    un=0;count=0
    for i in range(n):
        arr=[i for i in input().split()]
        m=int(arr[0])
        temp=0
        for j in range(1,m+1):
            if arr[j][0]!='B':
                temp+=1
        if temp>=count:
            un=i+1
            count = temp
    print(un,count)