Hii Everyone,
I posted one of the problems I didn’t able to solve during my NCR code wars 2020. Can anyone please help with how to solve this problem.
The problem statement is :
You bought N robots. Each robot has some intelligence, for example i th robot has the knowledge p[i]. While you playing with the robot she found a way to transfer the knowledge of the one robot to another.
In this process,you observe that, if X amount of knowledge is transferred from i th to j th ,then K % of knowledge that is transferred is gets dissipated(lost) in the process.
There fore your task is to make the knowledge of all robots equal and maximum.
Constraints:
1<= T <= 50
1<= N <= 100000
1<= k <= 99
0<= p[i] <= 100000, 0<= i < N
Input format
T - test cases
N , K
p1 p2 p3 … pN - array elements
Output:
print the float value of final array element.
sample input :
1
3 50
1 2 3
Sample Output :
1.7500
Explanation :
Robot 3 will transfer its 1.25 intelligence to Robot 1.
array will look like [1.625 , 2 , 1.75]
next Robot 2 will transfer its 0.25 intelligence to Robot 1.
array will lock like [1.75 , 1.75 ,1.75]
Final out put is 1.7500