Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[][][]dp;
- int max(int k, int x, int y){
- if(k == x){
- return 0;
- }
- if this state is visited {
- return dp[k][x][y];
- }
- int result = array[x][y];
- for(int i = y + 1; i < n; i++){
- result = max(result, array[x][y] + max(k + 1, y, i));
- }
- return dp[k][x][y] = result;
- }
Add Comment
Please, Sign In to add comment