Given lengths of n rods in an array a[]. If any person picks any rod, half of the longest rod (or (max + 1) / 2 ) is assigned and remaining part (max – 1) / 2 is put back. It may be assumed that sufficient number of rods are always available, answer M queries given in an array q[] to find the largest length of rod available for qith person, provided qi is a valid person number starting from 1.
Examples :
Input : a[] = {6, 5, 9, 10, 12}
q[] = {1, 3}
Output : 12 9
Maximum length of rod for Q-th person : https://www.geeksforgeeks.org/maximum-length-rod-q-th-person/