Java implementation of th approach
class GFG { final static int N = 100 ; final static int INT_MIN = Integer . MIN_VALUE ; static int dp [ ] [ ] = new int [ N ] [ 3 ] ; static int v [ ] [ ] = new int [ N ] [ 3 ] ;