Javelin Qualification solution codechef

Javelin Qualification solution codechef

There are NN players with IDs from 11 to NN, 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 NN players has thrown as A1,A2,,ANA1,A2,…,AN. 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 of MM cm, they qualify for the final round.

2) If after step 11, less than XX 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. Javelin Qualification solution codechef

You are given the best throws of the NN players in the qualification round A1,A2,,ANA1,A2,…,AN and the integers MM and XX. Print the list of the players who will qualify for the finals in increasing order of their IDs.

Input Format

  • The first line of input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
  • The first line of each test case contains three space-separated integers N,M,XN,M,X.
  • The second line of each test case contains NN space-separated integers A1,A2,,ANA1,A2,…,AN.

Output Format Javelin Qualification solution codechef

  • For each test case, print a single line containing K+1K+1 space-separated integers, where KK is the number of players qualified.
  • First, print the integer KK, then followed by a space, print KK space-separated integers ID1,ID2,,IDKID1,ID2,…,IDK where IDiIDi denotes the players’ ID who qualified for the finals.
  • You have to print the IDs of the qualified players in increasing order.


  • 1T10001≤T≤1000
  • 2XN302≤X≤N≤30
  • 5000Ai80005000≤Ai≤8000
  • 7000M80007000≤M≤8000
  • All AiAi-s are distinct

Sample Input 1  Javelin Qualification solution codechef

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 11: Since no player crosses the qualification mark, they are chosen based on the distance thrown. So player 33 who has thrown the maximum distance gets selected followed by the player 22. Now since we have got the required number of players, player 11 isn’t selected.

Test Case 22: Since all the players cross the qualification mark, they all are selected.

Test Case 33: The player 33 and player 44 cross the qualification mark. So for the third and final spot in the final, the player 11 is selected since he ha

Leave a Comment

Your email address will not be published.