Find minimum number K such that sum of array after multiplication by K exceed S | Java implementation of the approach ; Function to return the minimum value of k that satisfies the given condition ; Store sum of array elements ; Calculate the sum after ; Return minimum possible K ; Driver code
import java . io . * ; import java . lang . Math ; class GFG { static int findMinimumK ( int a [ ] , int n , int S ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } return ( int ) Math . ceil ( ( ( S + 1 ) * 1.0 ) / ( sum * 1.0 ) ) ; } public static void main ( String [ ] args ) { int a [ ] = { 10 , 7 , 8 , 10 , 12 , 19 } ; int n = a . length ; int S = 200 ; System . out . print ( findMinimumK ( a , n , S ) ) ; } }