Javelin Qualification solution codechef
There areplayers with IDs from to , who are participating in the Javelin throw competition which has two rounds. The first is the qualification round, followed by the final round. The qualification round has gotten over, and you are given the longest distance that each of the players has thrown as . Now, the selection process for the final round happens in the following two steps:
1) If the longest throw of a player in the qualification round is greater than or equal to the qualification mark ofcm, they qualify for the final round.
2) If after step, less than players have qualified for the finals, the remaining spots are filled by players who have thrown the maximum distance among the players who have not qualified yet.
You are given the best throws of theplayers in the qualification round and the integers and . Print the list of the players who will qualify for the finals in increasing order of their IDs.
Input Format Javelin Qualification solution codechef
- The first line of input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains three space-separated integers .
- The second line of each test case contains space-separated integers .
Output Format Javelin Qualification solution codechef
- For each test case, print a single line containing space-separated integers, where is the number of players qualified.
- First, print the integer , then followed by a space, print space-separated integers where denotes the players’ ID who qualified for the finals.
- You have to print the IDs of the qualified players in increasing order.
Constraints Javelin Qualification solution codechef
- All -s are distinct
Sample Input 1
3 3 8000 2 5000 5001 5002 3 5000 2 7999 7998 8000 4 6000 3 5999 5998 6000 6001
Sample Output 1
2 2 3 3 1 2 3 3 1 3 4
Test Case: Since no player crosses the qualification mark, they are chosen based on the distance thrown. So player who has thrown the maximum distance gets selected followed by the player . Now since we have got the required number of players, player isn’t selected.
Test Case: Since all the players cross the qualification mark, they all are selected.
Test Case: The player and player cross the qualification mark. So for the third and final spot in the final, the player is selected since he has the maximum distance thrown amongst the remaining two players.
Solution: Click here