#C7305. Taco Item Recommendation
Taco Item Recommendation
Taco Item Recommendation
You are given n items with their popularity scores and assigned categories. There are m distinct categories, numbered from 1 to m. Your task is to determine the most popular items for each category. For each category, output the indices (1-indexed) of the items that have the highest popularity score. If there are multiple items in a category with the same maximum score, output all of their indices in the order they appear in the input. If no item belongs to a certain category, simply output an empty line.
Note: The items are numbered starting at 1 according to the order of input.
Example:
Input: 5 3 10 20 20 30 10 1 2 2 3 1</p>Output: 1 5 2 3 4
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains two integers n and m, where n is the number of items and m is the number of categories.
- The second line contains n integers representing the popularity scores of the items.
- The third line contains n integers where each integer indicates the category (an integer from 1 to m) of the corresponding item.
outputFormat
Output m lines to standard output (stdout). The i-th line should contain the indices (1-indexed) of the item(s) in category i that have the highest popularity score, separated by spaces. If a category does not have any items, output an empty line for that category.
## sample5 3
10 20 20 30 10
1 2 2 3 1
1 5
2 3
4
</p>