Attendence Sheet

All submissions for this problem are available.
On the first class of CSE101, the teacher enters the classroom and hands out an attendance sheet to the CR(Class Representative). Everyone is supposed to write their names beside their student ID no. But there is a twist. The students are not allowed to use pens or pencils. The teacher will give the class a long string of capital English letters [AZ] and every student has to use a letter from that string to write their names. Any letter can only be used by one student. The excess letters will be returned to the teacher. There is a problem though. Some students could not find the letter they needed in the given string. So, the teacher gave them permission to change any letter into any other letter. For example, if there are two students in the class named “TOM” and “DOM” and the teacher gives the string “TOMTOM”, then TOM will use the $1^{st}$, $2^{nd}$ and $3^{rd}$ letters to write his name. DOM will use the $5^{th}$ and $6^{th}$ letter and change the $4^{th}$ letter (‘T’ into ‘D’) to fully write his name. Your job is to find the minimum number of letters that need to be changed, if all the students want to write their names. ###Input: The first line of input will contain an integer $N$ denoting the number of students in the class. Next, there will be $N$ lines. The $ith$ line will contain the name of the $ith$ student, without any spaces. Each name will be at most 50 characters long and contain only capital English letters. The last line of input will contain a string of length $L$ that was given by the teacher. The string which needs to be used. ###Constraints: $(1 \leq N \leq 20,000)$ $(1 \leq L \leq 10^6)$ ###Output: Output a single integer: the minimum number of letters that need to be changed. Output $1$ if it cannot be done. (if someone can’t write their name) ###Sample Input 1: 2 DEEN TOM MONTEDALA ###Sample Output 1: 1 ###Sample Input 2: 1 RAKIB WOW ###Sample Output 2: 1 ###Explanation: $1^{st}$ Case: TOM can use the letters ‘T’, ‘O’, ‘M’ from the string to write his name. No need to change anything. DEEN can use ‘D’, ‘E’ and ‘N’ that are already present in the string. But he will need another ‘E’. He has only two ‘A’s and an ‘L’ left. He can change any one of these 3 letters into an ‘E’ and write his name. Thus the answer is $1$. $2^{nd}$ Case: It is not possible for RAKIB to write his name in any way, since there are not enough letters.Author:  solaimanope 
Tags  solaimanope 
Date Added:  23042018 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, kotlin 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions