program in python the following problem We ask that you assist the ITPC by indicating the maximum total number of letters that can be printed on a set of N shirts that are valid to be worn by both teams. For example, if “PÉREZ”, “GONZÁLEZ” and “LÓPEZ” play in the U-18 team, while “GARCIA”, “PERALTA” and “RODRÍGUEZ” play in the U-21 team, the best thing is that a jersey has the prefix "G" with 1 letter (for "GONZALEZ" and "GARCIA" to use), another has the prefix "PER" with 3 letters (for "PÉREZ" and "PERALTA" to use), and another has a 0-letter prefix (to be used by “LOPEZ” and “RODRIGUEZ”). Thus, the answer in this case is 1 + 3 + 0 = 4. Entry Each test case is described using three lines. The first line contains an integer N that indicates the number of players in each of the two teams (1≤N≤104). The second line contains the surnames of the N players of the U-18 team. The third line contains the surnames of the N players of the U21 team. Each last name is a non-empty string of at most 100 characters made up of only uppercase letters. In each test case the total number of letters in the 2N surnames is at most 105, and two or more players from the same or different teams may have the same surname. The end of the entry is indicated by a line containing the number −1. Departure For each test case, print in the output a line containing an integer that represents the maximum total number of letters that can be printed in a set of N shirts that are valid to be used by both teams.
program in python the following problem
We ask that you assist the ITPC by indicating the maximum total number of letters that can be printed on a set of N shirts that are valid to be worn by both teams. For example, if “PÉREZ”, “GONZÁLEZ” and “LÓPEZ” play in the U-18 team, while “GARCIA”, “PERALTA” and “RODRÍGUEZ” play in the U-21 team, the best thing is that a jersey has the prefix "G" with 1 letter (for "GONZALEZ" and "GARCIA" to use), another has the prefix "PER" with 3 letters (for "PÉREZ" and "PERALTA" to use), and another has a 0-letter prefix (to be used by “LOPEZ” and “RODRIGUEZ”). Thus, the answer in this case is 1 + 3 + 0 = 4.
Entry
Each test case is described using three lines. The first line contains an integer N that indicates the number of players in each of the two teams (1≤N≤104). The second line contains the surnames of the N players of the U-18 team. The third line contains the surnames of the N players of the U21 team. Each last name is a non-empty string of at most 100 characters made up of only uppercase letters. In each test case the total number of letters in the 2N surnames is at most 105, and two or more players from the same or different teams may have the same surname. The end of the entry is indicated by a line containing the number −1.
Departure
For each test case, print in the output a line containing an integer that represents the maximum total number of letters that can be printed in a set of N shirts that are valid to be used by both teams.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps