fork download
  1. long dp[],array[];
  2. long rec(int i,int prv){ // 0-> len turn, 1--
  3. if ( i >= array.length )
  4. return 0;
  5.  
  6. if ( dp[i] != -1 )
  7. return dp[i];
  8.  
  9. if ( i == array.length - 3 ) {
  10. dp[i] = array[i] + array[i+1] + array[i+2];
  11. }
  12. else if ( i == array.length - 2 ) {
  13. dp[i] = array[i] + array[i+1];
  14. }
  15. else if ( i == array.length - 1 ) {
  16. dp[i] = array[i];
  17. }
  18. else {
  19. dp[i] =max( max(
  20. rec(i+2 , array.length) + array[i] ,
  21. rec(i+4 , array.length) + array[i] + array[i+1]),
  22. rec(i+6 , array.length) + array[i] + array[i+1] + array[i+2] );
  23. } return dp[i];
  24.  
  25. }
  26.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class, interface, or enum expected
    long dp[],array[];
    ^
Main.java:2: error: class, interface, or enum expected
    long rec(int i,int prv){                // 0-> len turn, 1--
    ^
Main.java:6: error: class, interface, or enum expected
        if ( dp[i] != -1 )
        ^
Main.java:9: error: class, interface, or enum expected
        if ( i == array.length - 3 ) {
        ^
Main.java:11: error: class, interface, or enum expected
        }
        ^
Main.java:14: error: class, interface, or enum expected
        }
        ^
Main.java:17: error: class, interface, or enum expected
        }
        ^
Main.java:23: error: class, interface, or enum expected
        } return dp[i];
        ^
Main.java:25: error: class, interface, or enum expected
    }
    ^
9 errors
stdout
Standard output is empty