#K76627. Taco: Recommend an Unpurchased Item
Taco: Recommend an Unpurchased Item
Taco: Recommend an Unpurchased Item
In this problem, you are given a list of items, each associated with a category, and a list of purchased items by the user. Your task is to recommend an item from a category in which the user has not yet made any purchase. In other words, if the user has not purchased any item from a specific category, then the first available item in that category (according to the input order) should be recommended. If there is no item from any such category, print (\texttt{No recommendation}).
Formally, let the items be given as ({(s_i, c_i)}_{i=1}^{n}) and the purchased item names be given as a set (P). First, determine the set of categories (C_P) corresponding to the purchased items. Then, the answer is the first item (s_i) such that (c_i \notin C_P).
Note: Ensure that you read from standard input (stdin) and write your answer to standard output (stdout).
inputFormat
The input is given via standard input and has the following format:
- The first line contains an integer (n) representing the number of available items.
- The following (n) lines each contain a string and an integer separated by space. The string (s_i) indicates the item name and the integer (c_i) indicates its category.
- The next line contains an integer (m) representing the number of purchased items.
- The following (m) lines each contain a string which is the name of a purchased item.
It is guaranteed that if an item is purchased, it appears in the list of available items.
outputFormat
Output a single line containing the name of the recommended item which belongs to a category in which the user has made no purchases. If there is no valid recommendation, output "No recommendation".## sample
5
apple 1
banana 2
grape 3
orange 1
melon 4
2
banana
grape
apple