#C5943. Top K Common Performers
Top K Common Performers
Top K Common Performers
In a coding competition, there are two rounds. In each round, the participants are ranked and their IDs are given in order. You are provided with two lists: one for round one and one for round two. Your task is to determine which participants appear in the top K positions in both rounds. If there are common participants in the top K of both rounds, output their IDs sorted in ascending order. Otherwise, output "None".
Formally, let the first list contain N distinct integers and the second list contain M distinct integers. You need to find the intersection of the first K elements from both lists and print the result in ascending order. If the intersection is empty, print "None".
The problem may be formulated using LaTeX as follows: [ \text{Let } A = [a_1, a_2, \dots, a_N], \quad B = [b_1, b_2, \dots, b_M]. \quad \text{Find } S = { x : x \in {a_1, a_2, \dots, a_K} \cap {b_1, b_2, \dots, b_K} }. ]
inputFormat
The input is read from standard input (stdin) and consists of three lines:
- The first line contains three space-separated integers: N, M, and K, where N is the number of participants in round one and M is the number in round two.
- The second line contains N space-separated integers representing the IDs of the participants in round one in ranked order.
- The third line contains M space-separated integers representing the IDs of the participants in round two in ranked order.
outputFormat
Output to standard output (stdout) a single line containing the IDs of the participants who are in the top K positions in both rounds, sorted in ascending order and separated by spaces. If there is no common participant among the top K of both rounds, output "None" (without quotes).## sample
5 7 3
1 2 3 4 5
3 1 2 6 7 8 9
1 2 3