Find minimum number K such that sum of array after multiplication by K exceed S | C # 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
using System ; 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 . Ceiling ( ( ( 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 ; Console . Write ( findMinimumK ( a , n , S ) ) ; } }