Driver code
int main ( ) { memset ( dp , -1 , sizeof ( dp ) ) ; n = 4 ; k = 2 ; int ele [ n + 1 ] = { 0 , 2 , 6 , 4 , 8 } ; int cost [ n + 1 ] = { 0 , 40 , 20 , 30 , 10 } ; int ans = minCost ( 1 , 0 , 1 , ele , cost ) ; if ( ans == 1e5 ) { ans = -1 ; } cout << ans << endl ; return 0 ; }