Function to check if it is possible to get desired result
static bool check ( int [ ] a , int [ ] b , int k , int x ) { int sum = 0 ; for ( int i = 0 ; i < a . Length ; i ++ ) { sum = sum + ( int ) Math . Pow ( Math . Max ( a [ i ] - x , 0 ) , b [ i ] ) ; } if ( sum <= k ) return true ; else return false ; }