HSBCOA #4
Find Most Frequently Purchased Products
估计简单评测数据准备中,可先阅读题面
考点(AI 标注)哈希计数
The manager of a grocery store tagGrocery wishes to determine which products are most popular with his customers (i.e. which products they purchase most frequently). The manager selects N customers who purchase a shopping bag of items containing M products, each labeled with a productID. By analyzing these M products, the manager wishes to find the productIDs of the distinct products that get purchased most frequently by at least K(given) customers. Write an algorithm to help the manager find the productIDs of the products that are most frequently purchased by the K customers. Input The first line of the input consists of two space-separated integers - tag_row, tag_col, representing the number of customers (N), the number of products in the shopping bag of each customer (M). The next N lines consist of M space-separated integers - tag[0], tag[1], ......., tag[M-1], representing the productIDs of the products contained in the shopping bag of each customer. The last line consists of an integer- K, input representing number of K customers who are chosen by the manager (K). Output Print space-separated integers representing the lexicographically sorted productIDs of the products that are most frequently purchased by the K customers. Constraints 1 ≤ tag_row ≤ 10³ 1 ≤ tag_col ≤ 10³ 1 ≤ K input ≤ tag_row 0 ≤ tag[0], tag[1], ......., tag[N-1] ≤ 10⁹