Driver Code
int main ( ) { int n = 4 ; int adj [ n ] [ 2 ] = { { 5000 , 3000 } , { 6000 , 2000 } , { 8000 , 1000 } , { 9000 , 6000 } } ; memset ( dp , -1 , sizeof ( dp ) ) ; cout << find ( 1 , 1 , n , adj ) + adj [ 0 ] [ 1 ] << endl ; return 0 ; }