Problem Statement:
Micro purchased an array having integer values. After playing it for a while, he got bored of it and decided to update value of its element. In one second he can increase value of each array element by . He wants each array element's value to become greater than or equal to . Please help Micro to find out the minimum amount of time it will take, for him to do so.
Input:
First line consists of a single integer, , denoting the number of test cases.
First line of each test case consists of two space separated integers denoting and .
Second line of each test case consists of space separated integers denoting the array .
First line consists of a single integer, , denoting the number of test cases.
First line of each test case consists of two space separated integers denoting and .
Second line of each test case consists of space separated integers denoting the array .
Output:
For each test case, print the minimum time in which all array elements will become greater than or equal to . Print a new line after each test case.
For each test case, print the minimum time in which all array elements will become greater than or equal to . Print a new line after each test case.
Programming using python 2.7.6:
T =
input() # Number of test cases
Result
=[]
while T:
N,K = map(int,raw_input().split())
A = map(int,raw_input().split()[:N])
if min(A) >= K:
print 0
else:
print(K - min(A))
T -=1
No comments:
Post a Comment