Guest User

Untitled

a guest
Feb 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. int[][][]dp;
  2. int max(int k, int x, int y){
  3. if(k == x){
  4. return 0;
  5. }
  6. if this state is visited {
  7. return dp[k][x][y];
  8. }
  9. int result = array[x][y];
  10. for(int i = y + 1; i < n; i++){
  11. result = max(result, array[x][y] + max(k + 1, y, i));
  12. }
  13. return dp[k][x][y] = result;
  14.  
  15. }
Add Comment
Please, Sign In to add comment